
    xkd                         d Z ddlZddlZddlZddlZ ej        d          Z G d d          Z G d d          Ze	dk    rd	Z
 ee
          Z ee           dS dS )
z;deb822 parser with support for comment headers and footers.    NTc            	       p   e Zd ZdZdefdZdedefdZdeddfdZded	eddfd
Zde	fdZ
ej        dedej        e         fd            Zej        dededej        eef         fd            Z	 ddedej        e         dej        ej        e         ef         fdZededefd            ZdefdZdS )SectionzcA single deb822 section, possibly with comments.

    This represents a single deb822 section.
    sectionc                 4   ddg}d}d}|                     d          D ]?}|                    d          r|dd          }||xx         |dz   z  cc<   5d}||dz   z  }@t          j        t	          j        |                    | _        |\  | _        | _        d S )N F
#   T)	split
startswithcollectionsOrderedDictapt_pkg
TagSectiontagsheaderfooter)selfr   comments
in_sectiontrimmed_sectionlines         4/usr/lib/python3/dist-packages/aptsources/_deb822.py__init__zSection.__init__   s    8
MM$'' 	+ 	+Ds## ABBx$$$t3$$$Jtd{*OO+G,>,O,OPP	#+ T[[[    keyreturnc                     | j         |         S )zGet the value of a field.r   r   r   s     r   __getitem__zSection.__getitem__,   s    y~r   Nc                     | j         |= dS )zDelete a fieldNr    r!   s     r   __delitem__zSection.__delitem__0   s    IcNNNr   valc                     || j         |<   dS )zSet the value of a field.Nr    )r   r   r%   s      r   __setitem__zSection.__setitem__4   s    	#r   c                 *    t          | j                  S N)boolr   r   s    r   __bool__zSection.__bool__8   s    DIr   c                     d S r)    r!   s     r   getzSection.get;       r   defaultc                     d S r)   r.   r   r   r1   s      r   r/   zSection.get?   r0   r   c                 B    	 | j         |         S # t          $ r |cY S w xY wr)   )r   KeyErrorr3   s      r   r/   zSection.getC   s7    	9S>! 	 	 	NNN	s    contentc                 r    | r4d                     d |                                 D                       dz   ndS )Nr	   c              3       K   | ]	}d |z   V  
dS )r
   Nr.   ).0r   s     r   	<genexpr>z*Section.__comment_lines.<locals>.<genexpr>N   s&      BBTcDjBBBBBBr   r   )join
splitlines)r6   s    r   __comment_lineszSection.__comment_linesK   sE     DIIBBW-?-?-A-ABBBBBTII	
r   c                     |                      | j                  d                    d | j                                        D                       z   |                      | j                  z   S )z+Canonical string rendering of this section.r   c              3   ,   K   | ]\  }}| d | dV  dS )z: r	   Nr.   )r9   kvs      r   r:   z"Section.__str__.<locals>.<genexpr>W   s2      BB1mmammmBBBBBBr   )_Section__comment_linesr   r;   r   itemsr   r+   s    r   __str__zSection.__str__S   sd       --ggBB	0A0ABBBBBC""4;//0	
r   r)   )__name__
__module____qualname____doc__strr   r"   r$   r'   r*   r,   typingoverloadOptionalr/   r   UnionstaticmethodrB   rD   r.   r   r   r   r      s        
, , , , ,$s s    s t    s      $     _s vs3    _ _s Q 6<3+?    _ 7; !'!3	foa(#-	.    
 
 
 
 
 \

 
 
 
 
 
 
r   r   c                   V    e Zd ZdZdej        fdZdej        e	         fdZ
defdZdS )FilezC
    Parse a given file object into a list of Section objects.
    fobjc                 v    |                                                     d          }d |D             | _        d S )N

c                 ,    g | ]}t          |          S r.   )r   r9   ss     r   
<listcomp>z!File.__init__.<locals>.<listcomp>c   s    666666r   )readr   sections)r   rQ   rY   s      r   r   zFile.__init__a   s6    99;;$$V,,66X666r   r   c                 *    t          | j                  S r)   )iterrY   r+   s    r   __iter__zFile.__iter__e   s    DM"""r   c                 J    d                     d | j        D                       S )NrS   c              3   4   K   | ]}t          |          V  d S r)   )rI   rU   s     r   r:   zFile.__str__.<locals>.<genexpr>i   s(      99a3q66999999r   )r;   rY   r+   s    r   rD   zFile.__str__h   s%    {{994=999999r   N)rE   rF   rG   rH   io
TextIOBaser   rJ   Iteratorr   r\   rI   rD   r.   r   r   rP   rP   \   sx         7R] 7 7 7 7#&/'2 # # # #: : : : : : :r   rP   __main__zV# Header
# More header
K1: V1
# Inline
K2: V2
 # not a comment
# Footer
# More footer
)rH   r_   r   rJ   r   TypeVarr   r   rP   rE   strV   printr.   r   r   <module>rf      s    B A 				       FN3E
 E
 E
 E
 E
 E
 E
 E
P: : : : : : : :  z
B 	A	E!HHHHH r   