
    8.g                         S r SSKrSSKrSSKrSSKr\R
                  " S5      r " S S5      r " S S5      r\	S:X  a  S	r
\" \
5      r\" \5        gg)
z;deb822 parser with support for comment headers and footers.    NTc                      \ rS rSr% Sr\R                  \\4   \S'   \	\\4   \S'   \\S'   \\S'   S\
R                  \S 4   4S jrS	\S
\4S jrS	\S
S4S jrS	\S\S
S4S jrS
\4S jr\
R$                  S	\S
\S-  4S j5       r\
R$                  S	\S\S
\\-  4S j5       rSS	\S\S-  S
\S-  \-  4S jjr\S\S
\4S j5       rS
\4S jrSrg)Section   z[A single deb822 section, possibly with comments.

This represents a single deb822 section.
tags_case_mappingheaderfootersectionc                    [        U[        5      (       ax  [        R                  " UR                  5      U l        U R                   Vs0 s H  o"R                  5       U_M     snU l        UR                  U l        UR                  U l        g SS/nSnSnUR                  S5       H8  nUR                  S5      (       a  USS  nX4==   US-   -  ss'   M/  SnXVS-   -  nM:     U(       a0  [        R                  " [        R                  " U5      5      U l        O[        R                  " 5       U l        U R                   Vs0 s H  o"R                  5       U_M     snU l        Uu  U l        U l        g s  snf s  snf )N F
#   T)
isinstancer   collectionsOrderedDictr   casefoldr   r	   r
   split
startswithapt_pkg
TagSection)selfr   kcomments
in_sectiontrimmed_sectionlines          4/usr/lib/python3/dist-packages/aptsources/_deb822.py__init__Section.__init__   s6   gw''#//=DI;?99!E9a**,/9!ED!..DK!..DK8
MM$'Ds##ABx$t3$Jd{*O ( #//0B0B?0STDI#//1DI7;yyAy!jjlAoyA#+ T[1 "F. Bs   	E4E9keyreturnc                 p    U R                   U R                  R                  UR                  5       U5         $ )zGet the value of a field.r   r   getr   r   r"   s     r   __getitem__Section.__getitem__:   s*    yy++//DEE    Nc                 n    U R                   U R                  R                  UR                  5       U5      	 g)zDelete a fieldNr%   r'   s     r   __delitem__Section.__delitem__>   s'    IId((,,S\\^SABr*   valc                     UR                  5       U R                  ;  a  XR                  UR                  5       '   X R                  U R                  UR                  5          '   g)zSet the value of a field.N)r   r   r   )r   r"   r.   s      r   __setitem__Section.__setitem__B   sG    <<>!3!3314s||~.8;		$$$S\\^45r*   c                 ,    [        U R                  5      $ N)boolr   r   s    r   __bool__Section.__bool__H   s    DIIr*   c                     g r3    r'   s     r   r&   Section.getK   s    +.r*   defaultc                     g r3   r9   r   r"   r;   s      r   r&   r:   N   s    47r*   c                 0     X   $ ! [          a    Us $ f = fr3   )KeyErrorr=   s      r   r&   r:   Q   s#    	9 	N	s    contentc                 f    U (       a)  SR                  S U R                  5        5       5      S-   $ S$ )Nr   c              3   ,   #    U  H
  nS U-   v   M     g7f)r   Nr9   ).0r   s     r   	<genexpr>*Section.__comment_lines.<locals>.<genexpr>Z   s     B-ATcDj-As   r   )join
splitlines)r@   s    r   __comment_linesSection.__comment_linesW   s8      IIBW-?-?-ABBTI	
 	
r*   c                     U R                  U R                  5      SR                  S U R                  R	                  5        5       5      -   U R                  U R
                  5      -   $ )z+Canonical string rendering of this section.r   c              3   6   #    U  H  u  pU S U S3v   M     g7f)z: r   Nr9   )rC   r   vs      r   rD   "Section.__str__.<locals>.<genexpr>c   s      B0A2aSm0As   )_Section__comment_linesr	   rF   r   itemsr
   r5   s    r   __str__Section.__str___   sU       -ggB		0ABBC""4;;/0	
r*   )r   r
   r	   r   r3   )__name__
__module____qualname____firstlineno____doc__r   r   str__annotations__dicttypingUnionr    r(   r,   r0   r4   r6   overloadr&   r   staticmethodrN   rP   __static_attributes__r9   r*   r   r   r      s<   
 
!
!#s(
++S>!KK,S)^ < ,:Fs Fs FCs Ct C<s < < <$  __.s.sTz. .__7s7Q71s77 7s QX TC  
 
 
 

 
r*   r   c                   p    \ rS rSrSrS\R                  4S jrS\R                  \
   4S jrS\4S jrSrg	)
Fileh   z;
Parse a given file object into a list of Section objects.
fobjc                    / U l         SnU HM  nUR                  5       (       d  X#-  nM  U(       d  M'  U R                   R                  [        U5      5        SnMO     U(       a%  U R                   R                  [        U5      5        g g )Nr   )sectionsisspaceappendr   )r   rb   r   r   s       r   r    File.__init__m   sl    D<<>>$$WW%56  MM  !12 r*   r#   c                 ,    [        U R                  5      $ r3   )iterrd   r5   s    r   __iter__File.__iter__}   s    DMM""r*   c                 F    SR                  S U R                   5       5      $ )Nr   c              3   8   #    U  H  n[        U5      v   M     g 7fr3   )rW   )rC   ss     r   rD   File.__str__.<locals>.<genexpr>   s     7AQs   )rF   rd   r5   s    r   rP   File.__str__   s    yy7777r*   )rd   N)rR   rS   rT   rU   rV   io
TextIOBaser    rZ   Iteratorr   rj   rW   rP   r^   r9   r*   r   r`   r`   h   s8    3R]] 3 #&//'2 #8 8r*   r`   __main__zV# Header
# More header
K1: V1
# Inline
K2: V2
 # not a comment
# Footer
# More footer
)rV   r   rq   rZ   r   TypeVarr   r   r`   rR   strn   printr9   r*   r   <module>rx      sd    B  	  
NN3S
 S
l8 88 z
B 	A	!H r*   