a ~_@s(dZddZddZGdddeZdS)zMailmap file reader.cCs>|dd\}}|}|d}|s.d}|s6d}||fS)N<>)rsplitstriprstrip)textnameZemailr 1/usr/lib/python3/dist-packages/dulwich/mailmap.pyparse_identitysr ccsj|D]`}|dd}|}|s$q|dd\}}|d7}|rNt|}nd}t|}||fVqdS)zRead a mailmap. Args: f: File-like object to read from Returns: Iterator over ((canonical_name, canonical_email), (from_name, from_email)) tuples #rrN)splitrr )flinecanonical_identity from_identityZparsed_from_identityZparsed_canonical_identityr r r read_mailmap%s rc@s8eZdZdZd ddZd ddZddZed d ZdS) Mailmapz#Class for accessing a mailmap file.NcCs(i|_|r$|D]\}}|||qdS)N)_table add_entry)selfmaprrr r r __init__@s zMailmap.__init__cCsb|durd\}}n|\}}|\}}|durP|durP||j|df<||jd|f<n||j||f<dS)aAdd 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)rrr from_nameZ from_emailZcanonical_nameZcanonical_emailr r r rFs  zMailmap.add_entrycCst|tsd}t|}nd}|d|df|ddffD]<}|j|}|dur6|dp\|d|dpj|df}qtq6|r||S|dd|ddSdS)z$Lookup an identity in this mailmail.FTNrr s s