
                         *    d Z d Zd Z G d de      Zy)zMailmap file reader.c                     | j                  dd      \  }}|j                         }|j                  d      j                         }|sd }|sd }||fS )N   <      >)rsplitstriprstrip)textnameemails      "lib/third_party/dulwich/mailmap.pyparse_identityr      sT     KKa(MT5::<DLL$$&E%=    c              #      K   | D ]r  }|j                  d      d   }|j                         }|s*|j                  dd      \  }}|dz  }|j                         rt        |      }nd}t        |      }||f t yw)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   N)splitr   r   )flinecanonical_identityfrom_identityparsed_from_identityparsed_canonical_identitys         r   read_mailmapr   %   s      zz$"zz|.2jjq.A+	]d" #1-#@ #' $23E$F!')=== s   A9A;c                   6    e Zd ZdZddZddZd Zed        Zy)Mailmapz#Class for accessing a mailmap file.Nc                 P    i | _         |r|D ]  \  }}| j                  ||        y y N)_table	add_entry)selfmapr   r   s       r   __init__zMailmap.__init__@   s0    7:3#]1=A 8; r   c                     |d\  }}n|\  }}|\  }}|%|#|| j                   |df<   || j                   d|f<   y|| j                   ||f<   y)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_entryF   sl      $.!Iz&3#Y
,>)!30BDKK,-1CDKKo-.1CDKK	:-.r   c                    t        |t              sd}t        |      }nd}|d|d   f|d   dffD ]9  }| j                  j	                  |      }|!|d   xs |d   |d   xs |d   f} n |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/HIx{ 3hqk45HIE!%!7!-&q)8Xa[&q)8Xa[  J OA;&!4t;;r   c                 h    t        |d      5 } | t        |            cd d d        S # 1 sw Y   y xY w)Nrb)openr   )clspathr   s      r   	from_pathzMailmap.from_patho   s&    $|A' s   (1r   )	__name__
__module____qualname____doc__r"   r   r/   classmethodr5    r   r   r   r   =   s*    -BD*<( ( (r   r   N)r9   r   r   objectr   r;   r   r   <module>r=      s    * 
>05(f 5(r   