§
    Ø'ëfÓ.  ã                   ó\  — d Z ddlZddlZddlZddlmZ 	 ddlZn+# e$ r#  ej	        d¦  «          ej
        d¦  «         Y nw xY w	 ddlmZmZ ddlmZ dZn# e$ r d	ZY nw xY w	 dd
lmZ dZn# e$ r
 	 dd„Zd	ZY nw xY wd„ Z	 	 	 dd„Zd„ Zej        dd„¦   «         Z G d„ d¦  «        ZdS )z>This module implements facilities to deal with Debian control.é    N)ÚLoggerz=Please install 'python3-debian' in order to use this utility.é   )ÚDeb822ParagraphElementÚparse_deb822_file)ÚDeb822TokenTF)Úone_value_per_line_formatterc                 ó    — t          d¦  «        ‚)NzHBug: The dummy one_value_per_line_formatter method should not be called!)ÚAssertionError)ÚindentationÚtrailing_separatorÚimmediate_empty_lines      ú4/usr/lib/python3/dist-packages/devscripts/control.pyr   r   ,   s   € õ ØVñ
ô 
ð 	
ó    c              #   óp   K  — d}dV — | D ]}|s|V — |j         sdV — d}|V — Œ|r|j         s|V — dV — d S )NTú Fú
)Úis_whitespace)Úvalue_tokensÚ	sep_tokenr   Úfirst_tokenÚtokens        r   Ú_emit_one_line_valuer   6   s€   è è € Ø€KØ
€I€I€IØð ð ˆØð 	ØˆOˆOˆOØÔ*ð Ø�	�	�	ØˆØˆˆˆˆØð  )Ô"9ð ØˆˆˆØ
€J€J€J€J€Jr   c                 ó°   ‡‡‡— t           st          d¦  «        ‚| dk    r| dk     rt          d¦  «        ‚t          | ‰|¬¦  «        Š‰dk     r‰S ˆˆˆfd„}|S )a5  Provide a formatter that can handle indentation and trailing separators

    This is a custom wrap-and-sort formatter capable of supporting wrap-and-sort's
    needs. Where possible it delegates to python-debian's own formatter.

    :param indentation: Either the literal string "FIELD_NAME_LENGTH" or a positive
    integer, which determines the indentation fields.  If it is an integer,
    then a fixed indentation is used (notably the value 1 ensures the shortest
    possible indentation).  Otherwise, if it is "FIELD_NAME_LENGTH", then the
    indentation is set such that it aligns the values based on the field name.
    This parameter only affects values placed on the second line or later lines.
    :param trailing_separator: If True, then the last value will have a trailing
    separator token (e.g., ",") after it.
    :param immediate_empty_line: Whether the value should always start with an
    empty line.  If True, then the result becomes something like "Field:
 value".
    This parameter only applies to the values that will be formatted over more than
    one line.
    :param max_line_length_one_liner: If greater than zero, then this is the max length
    of the value if it is crammed into a "one-liner" value.  If the value(s) fit into
    one line, this parameter will overrule immediate_empty_line.

    z5wrap_and_sort_formatter requires python-debian 0.1.44ÚFIELD_NAME_LENGTHr   z7indentation must be at least 1 (or "FIELD_NAME_LENGTH"))r   r   c              3   ó�  •K  — ‰dk    sJ ‚t          |¦  «        }d„ |D ¦   «         }t          d„ |D ¦   «         ¦  «        rsd|j        rdndz   }t          d„ |D ¦   «         ¦  «        }|t	          |¦  «        dz
  |z  z  }|t	          | ¦  «        dz   z  }|‰k    rt          ||‰	¦  «        E d {V —† d S  ‰| ||¦  «        E d {V —† d S )Nr   c                 ó.   — g | ]}|j         s|j        ¯|‘ŒS © )Ú
is_commentÚis_value©Ú.0Úxs     r   ú
<listcomp>z?wrap_and_sort_formatter.<locals>._formatter.<locals>.<listcomp>z   s&   € ÐSÐSÐS Q¸¼ÐSÈÌ
ÐS˜qÐSÐSÐSr   c              3   ó$   K  — | ]}|j         V — Œd S ©N)r   r    s     r   ú	<genexpr>z>wrap_and_sort_formatter.<locals>._formatter.<locals>.<genexpr>~   s$   è è € Ð7Ð7˜aˆqŒzÐ7Ð7Ð7Ð7Ð7Ð7r   r   c              3   ó>   K  — | ]}t          |j        ¦  «        V — Œd S r%   )ÚlenÚtextr    s     r   r&   z>wrap_and_sort_formatter.<locals>._formatter.<locals>.<genexpr>„   s*   è è € ÐEÐE¨A�C ¤™KœKÐEÐEÐEÐEÐEÐEr   é   )ÚlistÚallr   Úsumr(   r   )
Únamer   Úformatter_tokensÚ
all_tokensÚvalues_and_commentsÚchars_between_valuesÚ	total_lenÚ_chain_formatterÚmax_line_length_one_linerr   s
          €€€r   Ú
_formatterz+wrap_and_sort_formatter.<locals>._formatteru   s@  øè è € ð )¨1Ò,Ð,Ð,Ð,ÝÐ*Ñ+Ô+ˆ
ØSÐS¨*ÐSÑSÔSÐõ Ð7Ð7Ð#6Ð7Ñ7Ô7Ñ7Ô7ð 	ð $%¨YÔ-DÐ(K¨¨È!Ñ#LÐ åÐEÐEÐ1DÐEÑEÔEÑEÔEˆIà�#Ð1Ñ2Ô2°QÑ6Ð:NÑNÑNˆIà�˜T™œ Q™Ñ&ˆIØÐ5Ò5Ð5Ý/Ø'¨Ð4Fñô ð ð ð ð ð ð ð ð �ð $Ð# D¨)°ZÑ@Ô@Ð@Ð@Ð@Ð@Ð@Ð@Ð@Ð@Ð@r   )ÚHAS_FULL_RTS_FORMATTINGÚNotImplementedErrorÚ
ValueErrorr   )r   r   r   r5   r6   r4   s    ` ` @r   Úwrap_and_sort_formatterr:   E   s®   øøø€ õ8 #ð 
Ý!ØCñ
ô 
ð 	
ð Ð)Ò)Ð)¨k¸Aªo¨oÝÐRÑSÔSÐSõ 4ØØ-Ø1ðñ ô Ðð ! 1Ò$Ð$ØÐðAð Að Að Að Að Að Að< Ðr   c                 ó  — 	 | j          || |<   	 |                       ||¦  «         n# t          $ r Y nw xY wdS # t          $ r Y nw xY wd}| D ]+}|r|                      |¦  «        }|| |<   ||k    rd}|| |<   Œ,|s|| |<   dS dS )zbInsert new_item into directly after item_before

    New items added to a dictionary are appended.NFT)Úorder_afterÚKeyErrorÚAttributeErrorÚpop)Ú	paragraphÚitem_beforeÚnew_itemÚ	new_valueÚ
item_foundÚitemÚvalues          r   Ú_insert_afterrG   –   sú   € ðØÔÐð
 (ˆ	�(Ñð	Ø×!Ò! (¨KÑ8Ô8Ð8Ð8øÝð 	ð 	ð 	ð ˆDð	øøøð 	ˆøõ ð ð ð Øˆðøøøð €JØð ,ð ,ˆØð 	$Ø—M’M $Ñ'Ô'ˆEØ#ˆI�d‰OØ�;ÒÐØˆJØ"+ˆI�hÑøØð (Ø'ˆ	�(ÑÐÐð(ð (s   ‚8 �& ¦
3²3¸
AÁAúutf-8c              +   ór   K  — |€.t          | fd|i|¤Ž5 }|V — d d d ¦  «         d S # 1 swxY w Y   d S |V — d S )NÚencoding)Úopen)ÚfilenameÚfdrJ   ÚkwargsÚfileobjs        r   Ú_openrP   µ   sŸ   è è € à	€zÝ�(Ð8Ð8 XÐ8°Ð8Ð8ð 	¸GØˆMˆMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	ð ˆˆˆˆˆs   ”&¦*­*c                   ó\   — e Zd ZdZdd„Zed„ ¦   «         Zd„ Zd„ Zd„ Z	d„ Z
dd	„Zd
„ Zd„ ZdS )ÚControlz Represents a debian/control fileNc                 ón  — |€,t           j                             |¦  «        sJ |› d�¦   «         ‚|| _        || _        d| _        | j        rot          st          d¦  «        ‚t          ||d¬¦  «        5 }t          |¦  «        | _
        d d d ¦  «         n# 1 swxY w Y   t          | j
        ¦  «        | _        d S d | _
        g | _        t          ||d¬¦  «        5 }t          j        j                             |¦  «        D ]}| j                             |¦  «         Œ	 d d d ¦  «         d S # 1 swxY w Y   d S )Nz does not exist.Fz@The use_rts_parser option requires python-debian 0.1.43 or laterÚutf8)rM   rJ   )ÚosÚpathÚisfilerL   Ú_is_roundtrip_safeÚ!strip_trailing_whitespace_on_saveÚHAS_RTS_PARSERr9   rP   r   Ú_deb822_filer+   Ú
paragraphsÚdebianÚdeb822ÚDeb822Úiter_paragraphsÚappend)ÚselfrL   rM   Úuse_rts_parserÚsequencer@   s         r   Ú__init__zControl.__init__Á   sÑ  € Øˆ~¥¤§¢°Ñ!9Ô!9ˆ~ˆ~¸hÐ;XÐ;XÐ;X‰~Œ~ˆ~Ø ˆŒØ"0ˆÔØ16ˆÔ.àÔ"ð 	6õ "ð Ý ØVñô ð õ �x B°Ð8Ñ8Ô8ð @¸HÝ$5°hÑ$?Ô$?�Ô!ð@ð @ð @ñ @ô @ð @ð @ð @ð @ð @ð @øøøð @ð @ð @ð @å" 4Ô#4Ñ5Ô5ˆDŒOˆOˆOà $ˆDÔØ ˆDŒOÝ�x B°Ð8Ñ8Ô8ð 6¸HÝ!'¤Ô!5×!EÒ!EÀhÑ!OÔ!Oð 6ð 6�IØ”O×*Ò*¨9Ñ5Ô5Ð5Ð5ð6ð6ð 6ð 6ñ 6ô 6ð 6ð 6ð 6ð 6ð 6ð 6ð 6øøøð 6ð 6ð 6ð 6ð 6ð 6s%   Á3BÂBÂBÃAD*Ä*D.Ä1D.c                 ó   — | j         S r%   )rX   ©rb   s    r   Úis_roundtrip_safezControl.is_roundtrip_safeÛ   s   € àÔ&Ð&r   c                 óB   — | j         d                              d¦  «        S )z*Returns the value of the Maintainer field.r   Ú
Maintainer©r\   Úgetrg   s    r   Úget_maintainerzControl.get_maintainerß   s   € àŒ˜qÔ!×%Ò% lÑ3Ô3Ð3r   c                 óB   — | j         d                              d¦  «        S )z8Returns the value of the XSBC-Original-Maintainer field.r   úXSBC-Original-Maintainerrk   rg   s    r   Úget_original_maintainerzControl.get_original_maintainerã   s   € àŒ˜qÔ!×%Ò%Ð&@ÑAÔAÐAr   c                 óü   — | j         r|                      ¦   «         }n$d                     d„ | j        D ¦   «         ¦  «        }| j        r4d                     d„ |                     ¦   «         D ¦   «         ¦  «        dz   }|S )Nr   c              3   ó>   K  — | ]}|                      ¦   «         V — Œd S r%   )Údumpr    s     r   r&   zControl.dump.<locals>.<genexpr>ë   s*   è è € ÐBÐB¨Q §¢¡¤ÐBÐBÐBÐBÐBÐBr   c              3   ó>   K  — | ]}|                      ¦   «         V — Œd S r%   )Úrstripr    s     r   r&   zControl.dump.<locals>.<genexpr>í   s*   è è € ÐIÐI¨q §¢¡
¤
ÐIÐIÐIÐIÐIÐIr   )rh   Ú_dump_rts_fileÚjoinr\   rY   Ú
splitlines)rb   Úcontents     r   rs   zControl.dumpç   s…   € ØÔ!ð 	CØ×)Ò)Ñ+Ô+ˆGˆGà—i’iÐBÐB°$´/ÐBÑBÔBÑBÔBˆGØÔ1ð 	QØ—i’iÐIÐI°G×4FÒ4FÑ4HÔ4HÐIÑIÔIÑIÔIÈDÑPˆGØˆr   c                 ó<  — d}d}d}| j                              ¦   «         D ]{}t          |t          ¦  «        r%| j        |                              ¦   «         }|dz  }n3t          |t          ¦  «        r
|j        rd}Œ[|                     ¦   «         }|r|dz  }||z  }Œ||S )Nr   Ú Fr   Tr   )	r[   Ú
iter_partsÚ
isinstancer   r\   rs   r   r   Úconvert_to_text)rb   Úparagraph_indexÚnew_contentÚpending_newlineÚpartÚpart_contents         r   rv   zControl._dump_rts_fileð   sÃ   € ð ˆØˆØˆØÔ%×0Ò0Ñ2Ô2ð 	(ð 	(ˆDÝ˜$Õ 6Ñ7Ô7ð 6Ø#œ¨Ô?×DÒDÑFÔF�Ø 1Ñ$��Ý˜D¥+Ñ.Ô.ð 	6°4Ô3Eð 	6ð #'�Øà#×3Ò3Ñ5Ô5�Øð $Ø˜tÑ#�Ø˜<Ñ'ˆKˆKØÐr   c                 óì   — |r|| _         |                      ¦   «         }t          | j         d¦  «        5 }|                     |                     d¦  «        ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zSaves the control file.ÚwbrH   N)rL   rs   rK   ÚwriteÚencode)rb   rL   ry   Úcontrol_files       r   ÚsavezControl.save  s±   € àð 	%Ø$ˆDŒMØ—)’)‘+”+ˆÝ�$”- Ñ&Ô&ð 	8¨,Ø×Ò˜wŸ~š~¨gÑ6Ô6Ñ7Ô7Ð7ð	8ð 	8ð 	8ñ 	8ô 	8ð 	8ð 	8ð 	8ð 	8ð 	8ð 	8ð 	8øøøð 	8ð 	8ð 	8ð 	8ð 	8ð 	8s   ³)A)Á)A-Á0A-c                 ó&   — || j         d         d<   dS )z'Sets the value of the Maintainer field.r   rj   N)r\   )rb   Ú
maintainers     r   Úset_maintainerzControl.set_maintainer  s   € à+5ˆŒ˜Ô˜<Ñ(Ð(Ð(r   c                 ó‚   — d| j         d         v r|| j         d         d<   dS t          | j         d         dd|¦  «         dS )z5Sets the value of the XSBC-Original-Maintainer field.ro   r   rj   N)r\   rG   )rb   Úoriginal_maintainers     r   Úset_original_maintainerzControl.set_original_maintainer  s[   € à%¨¬¸Ô);Ð;Ð;Ø=PˆDŒO˜AÔÐ9Ñ:Ð:Ð:åØ” Ô"ØØ*Ø#ñ	ô ð ð ð r   )NNr%   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__re   Úpropertyrh   rm   rp   rs   rv   r‰   rŒ   r�   r   r   r   rR   rR   ¾   sº   € € € € € Ø*Ð*ð6ð 6ð 6ð 6ð4 ð'ð 'ñ „Xð'ð4ð 4ð 4ðBð Bð Bðð ð ðð ð ð<8ð 8ð 8ð 8ð6ð 6ð 6ð
ð 
ð 
ð 
ð 
r   rR   )TF)TFr   )NrH   )r“   Ú
contextlibrU   ÚsysÚdevscripts.loggerr   Údebian.deb822r]   ÚImportErrorÚerrorÚexitÚdebian._deb822_repror   r   Údebian._deb822_repro.tokensr   rZ   Údebian._deb822_repro.formatterr   r7   r   r:   rG   ÚcontextmanagerrP   rR   r   r   r   ú<module>r       só  ðð" EÐ DØ Ð Ð Ð Ø 	€	€	€	Ø 
€
€
€
à $Ð $Ð $Ð $Ð $Ð $ðØÐÐÐÐøØð ð ð Ø€F„LÐPÑQÔQÐQØ€C„HˆQ�K„K€K€K€KðøøøðØNÐNÐNÐNÐNÐNÐNÐNØ7Ð7Ð7Ð7Ð7Ð7à€N€NøØð ð ð Ø€N€N€Nðøøøð$ØKÐKÐKÐKÐKÐKà"ÐÐøØð 	$ð 	$ð 	$ð DIð
ð 
ð 
ð 
ð $ÐÐÐð	$øøøðð ð ð" ØØð	Nð Nð Nð Nðb(ð (ð (ð> Ôðð ð ñ Ôððfð fð fð fð fñ fô fð fð fð fs3   – ›%AÁAÁA ÁA"Á!A"Á&A/ Á/A>Á=A>