
    .PhD                     <    d Z ddlmZ d Zd Z G d d          ZdS )zMailmap file reader.    )Optionalc                     |                      dd          \  }}|                                }|                    d                                          }|sd }|sd }||fS )N   <      >)rsplitstriprstrip)textnameemails      O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/dulwich/mailmap.pyparse_identityr      si     KKa((MT5::<<DLL$$&&E  %=    c              #   *  K   | D ]}|                     d          d         }|                                }|s4|                     dd          \  }}|dz  }|                                rt          |          }nd}t          |          }||fV  dS )zRead a mailmap.

    Args:
      f: File-like object to read from
    Returns: Iterator over
        ((canonical_name, canonical_email), (from_name, from_email)) tuples
       #r   r   r   N)splitr	   r   )flinecanonical_identityfrom_identityparsed_from_identityparsed_canonical_identitys         r   read_mailmapr   (   s        > >zz$"zz|| 	.2jjq.A.A+	]d"   	(#1-#@#@  #' $23E$F$F!')======> >r   c                   B    e Zd ZdZdd	dZdd	dZd Zed             ZdS )
Mailmapz#Class for accessing a mailmap file.Nreturnc                 X    i | _         |r|D ]\  }}|                     ||           d S d S N)_table	add_entry)selfmapr   r   s       r   __init__zMailmap.__init__C   sY    RT 	B58 B B1"M1=AAAA	B 	BB Br   c                 ~    |d\  }}n|\  }}|\  }}|||| j         |df<   || j         d|f<   dS || j         ||f<   dS )a   Add an entry to the mail mail.

        Any of the fields can be None, but at least one of them needs to be
        set.

        Args:
          canonical_identity: The canonical identity (tuple)
          from_identity: The from identity (tuple)
        N)NN)r    )r"   r   r   	from_name
from_emailcanonical_namecanonical_emails          r   r!   zMailmap.add_entryI   st      $.!Izz&3#Y
,>)!30BDK,-1CDKo-...1CDK	:-...r   c                 6   t          |t                    sd}t          |          }nd}|d|d         f|d         dffD ]@}| j                            |          }|"|d         p|d         |d         p|d         f} nA|r|S |d         dz   |d         z   dz   S )z$Lookup an identity in this mailmail.FTNr   r   s    <r   )
isinstancetupler   r    get)r"   identity	was_tuplequeryr   s        r   lookupzMailmap.lookup^   s    (E** 	I%h//HHIx{ 3hqk45HI 	 	E!%!7!7!-&q)8Xa[&q)8Xa[  .  	<OA;&!4t;;r   c                     t          |d          5 } | t          |                    cd d d            S # 1 swxY w Y   d S )Nrb)openr   )clspathr   s      r   	from_pathzMailmap.from_pathr   s    $ 	(3|A''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   6::r   )r   N)	__name__
__module____qualname____doc__r$   r!   r1   classmethodr7    r   r   r   r   @   s        --B B B B BD D D D D*< < <( ( ( [( ( (r   r   N)r;   typingr   r   r   r   r=   r   r   <module>r?      so   ,        
 
 
> > >05( 5( 5( 5( 5( 5( 5( 5( 5( 5(r   