§
    cÌc+  ã                   ó  — d dl Z ddlmZ ddlmZ  G d„ d¦  «        Z G d„ d¦  «        Zdd	„Zd
„ Z G d„ d¦  «        Z	d„ Z
d„ Zdd„Zd„ Zd„ Z	 ddlmZ ddlmZ dS # e$ r#Z ej        e¦  «         ddlmZmZ Y dZ[dS dZ[ww xY w)é    Né   )Úosutils©ÚIterableFilec                   ó   — e Zd Zd„ Zd„ ZdS )Ú	RioWriterc                 ó"   — d| _         || _        d S ©NF)Ú_soft_nlÚ_to_file©ÚselfÚto_files     ú0/usr/lib/python3/dist-packages/breezy/bzr/rio.pyÚ__init__zRioWriter.__init__,   s   € ØˆŒØˆŒˆˆó    c                 óŠ   — | j         r| j                             d¦  «         |                     | j        ¦  «         d| _         d S )Nó   
T)r   r   Úwrite)r   Ústanzas     r   Úwrite_stanzazRioWriter.write_stanza0   sA   € ØŒ=ð 	'ØŒM×Ò Ñ&Ô&Ð&Ø�Š�T”]Ñ#Ô#Ð#ØˆŒˆˆr   N)Ú__name__Ú
__module__Ú__qualname__r   r   © r   r   r   r   *   s2   € € € € € ð ð  ð  ðð ð ð ð r   r   c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú	RioReaderz‹Read stanzas from a file as a sequence

    to_file can be anything that can be enumerated as a sequence of
    lines (with newlines.)
    c                 ó   — || _         d S ©N)Ú
_from_file)r   Ú	from_files     r   r   zRioReader.__init__>   s   € Ø#ˆŒˆˆr   c              #   óB   K  — 	 t          | j        ¦  «        }|€d S |V — Œr   )Úread_stanzar    )r   Úss     r   Ú__iter__zRioReader.__iter__A   s2   è è € ð	Ý˜DœOÑ,Ô,ˆAØˆyØ�à���ð	r   N)r   r   r   Ú__doc__r   r%   r   r   r   r   r   7   s<   € € € € € ðð ð$ð $ð $ðð ð ð ð r   r   c                 ó@   ‡ ‡— ˆˆ fd„}t           |¦   «         ¦  «        S )z6Produce a rio IterableFile from an iterable of stanzasc               3   ót   •K  — ‰�‰dz   V — d} ‰D ]&}| durdV — |                      ¦   «         E d {V —† d} Œ'd S )Nr   TF)Úto_lines)Úfirst_stanzar$   ÚheaderÚstanzass     €€r   Ústr_iterzrio_file.<locals>.str_iterL   sv   øè è € ØÐØ˜5‘.Ð Ð Ð ØˆØð 	!ð 	!ˆAØ 4Ð'Ð'Ø���Ø—z’z‘|”|Ð#Ð#Ð#Ð#Ð#Ð#Ð#Ø ˆLˆLð		!ð 	!r   r   )r,   r+   r-   s   `` r   Úrio_filer.   J   s8   øø€ ð!ð !ð !ð !ð !ð !õ ˜˜™
œ
Ñ#Ô#Ð#r   c              #   ó8   K  — 	 t          | ¦  «        }|€d S |V — Œr   )r#   )r!   r$   s     r   Úread_stanzasr0   X   s0   è è € ðÝ˜	Ñ"Ô"ˆØˆ9ØˆEØˆˆˆð	r   c                   ó†   — e Zd ZdZdgZd„ Zd„ Zed„ ¦   «         Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ ZeZd„ Zd„ ZdS )ÚStanzaa+  One stanza for rio.

    Each stanza contains a set of named fields.

    Names must be non-empty ascii alphanumeric plus _.  Names can be repeated
    within a stanza.  Names are case-sensitive.  The ordering of fields is
    preserved.

    Each field value must be either an int or a string.
    Úitemsc                 ó–   — g | _         |r=t          |                      ¦   «         ¦  «        D ]\  }}|                      ||¦  «         ŒdS dS )zqConstruct a new Stanza.

        The keyword arguments, if any, are added in sorted order to the stanza.
        N)r3   ÚsortedÚadd)r   ÚkwargsÚtagÚvalues       r   r   zStanza.__init__o   sa   € ð
 ˆŒ
Øð 	%Ý$ V§\¢\¡^¤^Ñ4Ô4ð %ð %‘
��UØ—’˜˜eÑ$Ô$Ð$Ð$ð	%ð 	%ð%ð %r   c                 óh  — t          |¦  «        s"t          d                     |¦  «        ¦  «        ‚t          |t          ¦  «        rnNt          |t
          ¦  «        rn8t          |t          ¦  «        rn"t          d|›dt          |¦  «        ›�¦  «        ‚| j	         
                    ||f¦  «         dS )z&Append a name and value to the stanza.zinvalid tag {!r}zinvalid type for rio value: z	 of type N)Ú	valid_tagÚ
ValueErrorÚformatÚ
isinstanceÚbytesÚstrr2   Ú	TypeErrorÚtyper3   Úappend)r   r8   r9   s      r   r6   z
Stanza.addy   s¶   € å˜‰~Œ~ð 	=ÝÐ/×6Ò6°sÑ;Ô;Ñ<Ô<Ð<Ý�e�UÑ#Ô#ð 	4ØÝ˜�sÑ#Ô#ð 	4ØÝ˜�vÑ&Ô&ð 	4Øå�)Ø$˜u˜u¥d¨5¡k¤k kð3ñ 4ô 4ð 4àŒ
×Ò˜3 ˜,Ñ'Ô'Ð'Ð'Ð'r   c                 ó(   —  | ¦   «         }||_         |S r   ©r3   )ÚclsÚpairsÚrets      r   Ú
from_pairszStanza.from_pairsˆ   s   € àˆc‰eŒeˆØˆŒ	Øˆ
r   c                 ó2   — | j         D ]\  }}||k    r dS ŒdS )z=True if there is any field in this stanza with the given tag.TFrE   )r   Úfind_tagr8   r9   s       r   Ú__contains__zStanza.__contains__Ž   s1   € àœ*ð 	ð 	‰JˆC�Ø�hŠˆØ�t�tð àˆur   c                 ó*   — t          | j        ¦  «        S )z%Return number of pairs in the stanza.)Úlenr3   ©r   s    r   Ú__len__zStanza.__len__•   s   € å�4”:‰ŒÐr   c                 óP   — t          |t          ¦  «        sdS | j        |j        k    S r
   )r>   r2   r3   ©r   Úothers     r   Ú__eq__zStanza.__eq__™   s(   € Ý˜%¥Ñ(Ô(ð 	Ø�5ØŒz˜Uœ[Ò(Ð(r   c                 ó.   — |                       |¦  «         S r   )rT   rR   s     r   Ú__ne__zStanza.__ne__ž   s   € Ø—;’;˜uÑ%Ô%Ð%Ð%r   c                 ó   — d| j         z  S )Nz
Stanza(%r)rE   rO   s    r   Ú__repr__zStanza.__repr__¡   s   € Ø˜dœjÑ(Ð(r   c                 ó*   — t          | j        ¦  «        S )z$Return iterator of tag, value pairs.)Úiterr3   rO   s    r   Ú
iter_pairszStanza.iter_pairs¤   s   € å�D”JÑÔÐr   c                 óZ  — | j         sg S g }| j         D �]\  }}|                     d¦  «        }t          |t          ¦  «        r|                     dd¦  «        }n,t          |t          ¦  «        r|                     ¦   «         }n|}|dk    r|                     |dz   ¦  «         Œ’d|v rb|                     d¦  «        }|                     |dz   |d         z   dz   ¦  «         |d	d
…         D ]}|                     d|z   dz   ¦  «         ŒŒø|                     |dz   |z   dz   ¦  «         �Œ|S )z{Generate sequence of lines for external version of this file.

        The lines are always utf-8 encoded strings.
        Úasciizutf-8Úsurrogateescaper   s   : 
r   s   : r   é   Nó   	)r3   Úencoder>   r@   r2   Ú	to_stringrC   Úsplit)r   ÚresultÚtext_tagÚ
text_valuer8   r9   Ú	val_linesÚlines           r   r)   zStanza.to_lines¨   sW  € ð
 Œzð 	àˆIØˆØ$(¤Jð 	;ñ 	;Ñ ˆH�jØ—/’/ 'Ñ*Ô*ˆCÝ˜*¥cÑ*Ô*ð #Ø"×)Ò)¨'Ð3DÑEÔE��Ý˜J­Ñ/Ô/ð #Ø"×,Ò,Ñ.Ô.��à"�Ø˜Š|ˆ|Ø—’˜c G™mÑ,Ô,Ð,Ð,Ø˜%��à!ŸKšK¨Ñ.Ô.�	Ø—’˜c E™k¨I°a¬LÑ8¸5Ñ@ÑAÔAÐAØ% a b bœMð 8ð 8�DØ—M’M %¨$¡,°Ñ"6Ñ7Ô7Ð7Ð7ð8ð —’˜c E™k¨EÑ1°EÑ9Ñ:Ô:Ð:Ñ:Øˆr   c                 óP   — d                      |                      ¦   «         ¦  «        S )z Return stanza as a single stringr   )Újoinr)   rO   s    r   rb   zStanza.to_stringÅ   s   € à�xŠx˜Ÿš™œÑ(Ô(Ð(r   c                 óT   — |                      |                      ¦   «         ¦  «         dS )zWrite stanza to a fileN)Ú
writelinesr)   r   s     r   r   zStanza.writeÉ   s$   € à×Ò˜4Ÿ=š=™?œ?Ñ+Ô+Ð+Ð+Ð+r   c                 óN   — | j         D ]\  }}||k    r|c S Œt          |¦  «        ‚)z²Return the value for a field wih given tag.

        If there is more than one value, only the first is returned.  If the
        tag is not present, KeyError is raised.
        )r3   ÚKeyError)r   r8   ÚtÚvs       r   Úgetz
Stanza.getÍ   s>   € ð ”Jð 	 ð 	 ‰DˆAˆqØ�CŠxˆxØ���ð õ ˜3‘-”-Ðr   c                 óZ   — g }| j         D ] \  }}||k    r|                     |¦  «         Œ!|S r   )r3   rC   )r   r8   Úrro   rp   s        r   Úget_allzStanza.get_allÛ   s:   € ØˆØ”Jð 	ð 	‰DˆAˆqØ�CŠxˆxØ—’˜‘”�øØˆr   c                 ó.   — i }| j         D ]
\  }}|||<   Œ|S )zBReturn a dict containing the unique values of the stanza.
        rE   )r   Údr8   r9   s       r   Úas_dictzStanza.as_dictâ   s.   € ð ˆØœ*ð 	ð 	‰JˆC�ØˆAˆc‰FˆFØˆr   N)r   r   r   r&   Ú	__slots__r   r6   ÚclassmethodrI   rL   rP   rT   rV   rX   r[   r)   rb   r   rq   Ú__getitem__rt   rw   r   r   r   r2   r2   a   s  € € € € € ð	ð 	ð �	€Ið%ð %ð %ð(ð (ð (ð ðð ñ „[ðð
ð ð ðð ð ð)ð )ð )ð
&ð &ð &ð)ð )ð )ð ð  ð  ðð ð ð:)ð )ð )ð,ð ,ð ,ð
 ð 
 ð 
 ð €Kðð ð ðð ð ð ð r   r2   c                 ó    — t          | ¦  «        S r   ©Ú
_valid_tag)r8   s    r   r;   r;   ë   s   € Ý�c‰?Œ?Ðr   c                 ó    — t          | ¦  «        S )aó  Return new Stanza read from list of lines or a file

    Returns one Stanza that was read, or returns None at end of file.  If a
    blank line follows the stanza, it is consumed.  It's not an error for
    there to be no blank at end of file.  If there is a blank file at the
    start of the input this is really an empty stanza and that is returned.

    Only the stanza lines and the trailing blank (if any) are consumed
    from the line_iter.

    The raw lines must be in utf-8 encoding.
    ©Ú_read_stanza_utf8©Ú	line_iters    r   r#   r#   ï   s   € õ ˜YÑ'Ô'Ð'r   éH   c                 ó®  — |dk    rt          |¦  «        ‚|dz
  }g }|                      ¦   «         D �]¢}|                     d¦  «        dd…         D �]€}t          j        dd|¦  «        }t          |¦  «        dk    �rS|d|…         }||d…         }t          |¦  «        dk    r�|dd	…         d
gk    rrd}|                     d
d¦  «        }|dk     r|                     dd¦  «        }|d	z  }|dk     r|                     dd¦  «        }|dk    r||d…         |z   }|d|…         }t          |¦  «        dk    rd|z   }t          j        dd|¦  «        }d}t          |¦  «        dk    r|dz  }nt          j        d|¦  «        r|dz  }d}|                     d|z   dz   ¦  «         |r|                     d¦  «         t          |¦  «        dk    �°S�Œ‚�Œ¤|S )aw  Convert a stanza into RIO-Patch format lines.

    RIO-Patch is a RIO variant designed to be e-mailed as part of a patch.
    It resists common forms of damage such as newline conversion or the removal
    of trailing whitespace, yet is also reasonably easy to read.

    :param max_width: The maximum number of characters per physical line.
    :return: a list of lines
    é   é   r   Néÿÿÿÿó   \\s   \\\\r   r_   ó    iìÿÿÿé   ó   -ó   /s     ó   s   \\rFó   \s    $Tó   # s   #   
)	r<   r)   rc   ÚreÚsubrN   ÚrfindÚsearchrC   )	r   Ú	max_widthÚmax_rio_widthÚlinesÚplinerh   ÚpartlineÚbreak_indexÚ
blank_lines	            r   Úto_patch_linesr›   ÿ   s  € ð �A‚~€~Ý˜Ñ#Ô#Ð#Ø ‘M€MØ€EØ—’Ñ"Ô"ð ,ñ ,ˆØ—K’K Ñ&Ô& s¨ sÔ+ð 	,ñ 	,ˆDÝ”6˜' ;°Ñ5Ô5ˆDÝ�d‘)”)˜a’-‘-Ø   Ô/�Ø˜M˜N˜NÔ+�Ý�t‘9”9˜q’=�= T¨"¨1¨"¤X°$°Ò%7Ð%7Ø"$�KØ"*§.¢.°°sÑ";Ô";�KØ" Q’�Ø&.§n¢n°T¸3Ñ&?Ô&?˜Ø# qÑ(˜Ø" Q’�Ø&.§n¢n°T¸3Ñ&?Ô&?˜Ø" aÒ'Ð'Ø'¨¨¨Ô5¸Ñ<˜Ø#+¨L¨[¨LÔ#9˜Ý�t‘9”9˜q’=�=Ø  4™<�DÝœ6 %¨°8Ñ<Ô<�Ø"�
Ý�t‘9”9˜q’=�=Ø Ñ%�H�HÝ”Y˜u hÑ/Ô/ð &Ø Ñ%�HØ!%�JØ—’˜U XÑ-°Ñ5Ñ6Ô6Ð6Øð ,Ø—L’L Ñ+Ô+Ð+õ3 �d‘)”)˜a’-‘-ùñ	,ð8 €Lr   c              #   óÖ  ‡K  — ddddœŠˆfd„}d }| D ]Í}|                      d¦  «        r|dd …         }nB|                      d¦  «        r|d	d …         }n"t          d
                     |¦  «        ¦  «        ‚|�t          |¦  «        dk    r
|dd …         }t	          j        dd|¦  «        }t	          j        d||¦  «        }|€|}n||z  }|dd …         dk    r|V — d }ŒÎ|�|V — d S d S )NrŽ   r�   r   )rˆ   s   \rs   \
c                 ó:   •— ‰|                       d¦  «                 S )Nr   )Úgroup)ÚmatchÚmaps    €r   Úmapgetz"_patch_stanza_iter.<locals>.mapget2  s   ø€ Ø�5—;’;˜q‘>”>Ô"Ð"r   r�   r   ó   #r_   zbad line {!r}s   \\(.|
)r‡   r   )Ú
startswithr<   r=   rN   r�   r‘   )r‚   r¡   Ú	last_linerh   r    s       @r   Ú_patch_stanza_iterr¥   -  sH  øè è € ØØØðð €Cð#ð #ð #ð #ð #ð €IØð ð ˆØ�?Š?˜5Ñ!Ô!ð 	;Ø˜˜˜”8ˆDˆDØ�_Š_˜TÑ"Ô"ð 	;Ø˜˜˜”8ˆDˆDå˜_×3Ò3°DÑ9Ô9Ñ:Ô:Ð:ØÐ ¥S¨¡Y¤Y°¢] ]Ø˜˜˜”8ˆDÝŒv�e˜S $Ñ'Ô'ˆÝŒv�m V¨TÑ2Ô2ˆØÐØˆIˆIà˜ÑˆIØ�R�S�SŒ>˜UÒ"Ð"ØˆOˆOˆOØˆIøØÐØˆˆˆˆˆð Ðr   c                 ó:   — t          t          | ¦  «        ¦  «        S )a5  Convert an iterable of RIO-Patch format lines into a Stanza.

    RIO-Patch is a RIO variant designed to be e-mailed as part of a patch.
    It resists common forms of damage such as newline conversion or the removal
    of trailing whitespace, yet is also reasonably easy to read.

    :return: a Stanza
    )r#   r¥   r�   s    r   Úread_patch_stanzar§   L  s   € õ Õ)¨)Ñ4Ô4Ñ5Ô5Ð5r   r_   r   r|   )r€   r}   r   )rƒ   )r�   Ú r   Úiterablefiler   r   r   r.   r0   r2   r;   r#   r›   r¥   r§   Ú_rio_pyxr€   Ú_rio_rsr}   ÚImportErrorÚeÚfailed_to_load_extensionÚ_rio_pyr   r   r   ú<module>r°      sï  ððB 
€	€	€	à Ð Ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'ð
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ðð ð ð ð ñ ô ð ð&$ð $ð $ð $ðð ð ðGð Gð Gð Gð Gñ Gô Gð GðTð ð ð(ð (ð (ð +ð +ð +ð +ð\ð ð ð>	6ð 	6ð 	6ð
ð
ð 
ð 
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
øð ð 
ð 
ð 
Ø$€GÔ$ QÑ'Ô'Ð'ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
øøøøð
øøøs   ÁA ÁBÁ#BÂB