
    )g$                        S SK r S SKr S SKrS SKrS SKrS SKJr  S SKJrJ	r	J
r
JrJrJrJrJrJrJr  S SKJr  S SKJrJrJr  \\
\	\\4      /\
\	\\4      4   r\(       a  S SKJr  S SKJr  SSS	.S
 jrSS.S jr\R>                  S:  d  \(       a  \ R
                  R                  \   r O$ " S S\ R
                  R                  \\   \5      r  " S S\ \   \\   5      r! SS jr"g)    N)ABC)
OptionalUnionIterableCallableTYPE_CHECKINGIteratorTypecastListGeneric)T)TERTokenOrElementDeb822Element)Deb822Token   )end_marker_afteroutput_functionc          	         SSK Jn  Sn[        X5      (       a  U /n SS[        U 5      4/nSnUc  [        R
                  nU(       a  US   u  pxn	U	 H  n
US-  nUc  S[        U5      -  n[        X5      (       a`  UR                  XjR                  R                  [        U
R                  5       5      45        U" XJR                  R                  -   5        Sn  O[U" U[        U
5      -   5        M     UR                  5         SnUb.  Xq-   U::  a&  U(       a  Uc  S[        U5      -  nU" US-   U-   5        U(       a  M  gg)	aN  Debugging aid, which can dump a Deb822Element or a list of tokens/elements

:param ast_tree: Either a Deb822Element or an iterable Deb822Token/Deb822Element entries
  (both types may be mixed in the same iterable, which enable it to dump the
  ast tree at different stages of parse_deb822_file method)
:param end_marker_after: The dump will add "end of element" markers if a
  given element spans at least this many tokens/elements. Can be disabled
  with by passing None as value. Use 0 for unconditionally marking all
  elements (note that tokens never get an "end of element" marker as they
  are not an elements).
:param output_function: Callable that receives a single str argument and is responsible
  for "displaying" that line. The callable may be invoked multiple times (one per line
  of output).  Defaults to logging.info if omitted.

r   r   N    z  z# <-- END OF )debian._deb822_repro.parsingr   
isinstanceiterlogginginfolenappend	__class____name__
iter_partsstrpop)ast_treer   r   r   prefixstack
current_nostart_nonamecurrent_itercurrents              </usr/lib/python3/dist-packages/debian/_deb822_repro/_util.py	print_astr1      s1   . ;F(**:T(^$%EJ!,,
',Ry$#G!OJ~E
*'11j*;*;*D*Dd7K]K]K_F`ab):):)C)C CDFS\12 $ IIKF+0Kz0Y^b>!CJ.F 84 ?@' %    )constructorc                <   ^ ^ Uc  [        SU5      mOUmUU 4S jnU$ )zCombines runs of one type into another type

This is primarily useful for transforming tokens (e.g, Comment tokens) into
the relevant element (such as the Comment element).
zCallable[[List[TE]], R]c              3      >#    / nU  HU  n[        UT5      (       a  UR                  U5        M'  U(       a#  T" [        U5      5      v   UR                  5         Uv   MW     U(       a  T" U5      v   g g 7fN)r   r"   listclear)token_streamtokenstoken_constructorsource_classs      r0   _impl'combine_into_replacement.<locals>._impl_   sf     !E%..e$"4<00K " v&& s   A1A4)r   )r=   replacement_classr3   r>   r<   s   `   @r0   combine_into_replacementrA   N   s,     57HI #'  Lr2   )   	   c                       \ rS rSrSrg)_bufferingIterator_Basew    N)r$   
__module____qualname____firstlineno____static_attributes__rG   r2   r0   rE   rE   w   s    r2   rE   c                   V    \ rS rSrS rS rS rS rS r SS jr	S	 r
S
 rS rS rSrg)BufferingIterator{   c                 f    [        U5      U l        [        R                  " 5       U l        SU l        g )NF)r   _streamcollectionsdeque_buffer_expired)selfstreams     r0   __init__BufferingIterator.__init__}   s$    F|"((*r2   c                     U R                   (       a  U R                   R                  5       $ U R                  (       a  [        e[	        U R
                  5      $ r6   )rS   popleftrT   StopIterationnextrP   rU   s    r0   __next__BufferingIterator.__next__   s8    <<<<''))==DLL!!r2   c              #      #    U R                   nU(       d  U R                  S5      (       aJ  US   nU" U5      (       a  UR                  5         Uv   OgU(       a  M1  U R                  S5      (       a  MI  gg7f)zVVariant of itertools.takewhile except it does not discard the first non-matching tokenr   r   N)rS   _fill_bufferrZ   )rU   	predicatebuffervs       r0   	takewhileBufferingIterator.takewhile   s^      ))!,,q	A||  f))!,,s   AA7A75A7c                     U R                  U5        U R                  n[        U5      U:X  a  [        U5      nUR	                  5         U$ / nU(       a;  U(       a4  UR                  UR                  5       5        US-  nU(       a	  U(       a  M4  U$ Nr   )ra   rS   r!   r7   r8   r"   rZ   )rU   countrc   rets       r0   consume_manyBufferingIterator.consume_many   sv    % v;%v,CLLN 
	 CU

6>>+,
 UU 
r2   c                 ,    [        U R                  5      $ r6   )r7   rS   r]   s    r0   peek_bufferBufferingIterator.peek_buffer   s    DLL!!r2   Nc                     U R                   nSnUb  XB:  aZ  U[        U5      :  a$  U R                  US-   5        U[        U5      :  a  g X4   nU" U5      (       a  US-   $ US-  nUc  MS  XB:  a  MZ  g )Nr   r   r   )rS   r!   ra   )rU   rb   limitrc   ird   s         r0   	peek_findBufferingIterator.peek_find   sz    
 mqyCK!!!a%(F#	A||1uFA mqy r2   c                 D   U R                   (       dc  [        U R                  5      U:  aJ   U R                  R                  [	        U R
                  5      5        [        U R                  5      U:  a  MJ  [        U R                  5      $ ! [         a    SU l          M)  f = f)NT)rT   r!   rS   r"   r\   rP   r[   bool)rU   numbers     r0   ra   BufferingIterator._fill_buffer   sy    }}dll#f,LL''T\\(:; dll#f, DLL!! % $(DMs   .B
 
BBc                 $    U R                  S5      $ rh   )peek_atr]   s    r0   peekBufferingIterator.peek   s    ||Ar2   c                 ~    U R                  U5        [        U R                  5      U:  a  U R                  US-
     $ S $ rh   )ra   r!   rS   )rU   tokens_aheads     r0   rz   BufferingIterator.peek_at   s:    ,'14T\\1Bl1Rt||L1,-\X\\r2   c                     U R                  U5        U R                  n[        U5      U:X  a  [        U5      nU$ U(       a.  / nU H#  nUR	                  U5        US-  nU(       a  M"    U$     U$ / nU$ rh   )ra   rS   r!   r7   r"   )rU   rw   rc   rj   ts        r0   	peek_manyBufferingIterator.peek_many   s    &!v;& v,C 
 C

1!v 
  
 C
r2   )rS   rT   rP   r6   )r$   rH   rI   rJ   rW   r^   re   rk   rn   rs   ra   r{   rz   r   rK   rG   r2   r0   rM   rM   {   s:    "
" $	"]
r2   rM   c              #     #    Uc  [        U 5      nSnU HC  n [        SU5      R                  5       nU H  nU[        UR                  5      -  nM     Uv   ME     X2:w  ac  X2:  a/  [
        R                  " S5      R                  X2U S9n[        U5      e[
        R                  " S5      R                  X2U S9n[        U5      eg! [         a'    [        SU5      nU[        UR                  5      -  n Nf = f7f)zOFlatten a parser's output into tokens and verify it covers the entire line/textNr   r   r   z            Value parser did not fully cover the entire line with tokens (
            missing range {covered}..{content_len}).  Occurred when parsing "{content}"
            )coveredcontent_lencontentz                    Value parser emitted tokens for more text than was present?  Should have
                     emitted {content_len} characters, got {covered}. Occurred when parsing
                     "{content}"
                    )	r!   r   iter_tokenstextAttributeErrortextwrapdedentformat
ValueError)r   rV   r   r   token_or_elementr:   r;   msgs           r0   len_check_iteratorr      s     'lG"	+/+;<HHJF
  3uzz?*   #  // #  'R  S/!oo    RYZ	 	
 o   	'(89Es5::&G	's(   C9CBC9.C63C95C66C9r6   )#rQ   collections.abcr   sysr   abcr   typingr   r   r   r   r   r	   r
   r   r   r   debian._utilr   debian._deb822_repro.typesr   r   r   _combine_parts_ret_typer   r   debian._deb822_repro.tokensr   r1   rA   version_inforE   rM   r   rG   r2   r0   <module>r      s       
      < <"eNB&'()U>1$%&' 
 :7
  !"2Ap *.!H v)oo66q9+//":":GAJ c/2GAJ cP $("r2   