)uyc<%ddlZddlZddlZddlZddlZddlmZ ddlmZm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZmZmZe e e eefge e eeffZn#e$rdZ dZYnwxYwe r ddlmZdd lmZd dd d Zdd dZej dkse rejj eZ!n Gddejj eeeZ!Gdde!eeeZ" ddZ#dS)N)ABC) OptionalUnionIterableCallable TYPE_CHECKINGIteratorTypecastListGeneric)T)TERTokenOrElementFc|SN)tvs rs Deb822Element) Deb822Token)end_marker_afteroutput_functionc ddlm}d}t||r|g}ddt|fg}d}| tj}|r|d\}}} | D]} |dz }|dt |z}t| |r]||| jj t| f||| jj zd}nd||t| z| d}|0||z|kr'|r%|dt |z}||dz|z|dSdS) a~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. rrNz z # <-- END OF ) debian._deb822_repro.parsingr isinstanceiterlogginginfolenappend __class____name__ iter_partsstrpop) ast_treerrrprefixstack current_nostart_noname current_itercurrents r print_astr8s.;::::: F(M**:T(^^ $ %EJ!, A',Ry$$ # A AG !OJ~E *'=11  j'*;*Dd7K]K]K_K_F`F`abbb):)C CDDD OFS\\1 2 2 2 2 IIKKKF+;K0Kz0Y0Y^b0Y>!CJJ.F 84 ?@@@' AAAAAr) constructorc@|td|n|fd}|S)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). NzCallable[[List[TE]], R]c3Kg}|D]\}t|r||(|r.t|V||V]|r|VdSdSr)r%r*listclear) token_streamtokenstoken _constructor source_classs r_implz'combine_into_replacement.._imples!  E%..  e$$$ "l4<<00000 KKKK  ',v&& & & & & & ' 'r)r )rBreplacement_classr9rCrAs` @rcombine_into_replacementrETsK57HII # '''''' Lr) ceZdZdS)_bufferingIterator_BaseN)r, __module__ __qualname__rrrrIrI}s rrIcNeZdZdZdZdZdZdZ d dZdZ d Z d Z d Z dS) BufferingIteratorclt||_tj|_d|_dS)NF)r&_stream collectionsdeque_buffer_expired)selfstreams r__init__zBufferingIterator.__init__s*F|| "(**  rc|jr|jS|jrtt |jSr)rRpopleftrS StopIterationnextrOrTs r__next__zBufferingIterator.__next__s@ < *<'')) ) =  DL!!!rc#K|j}|s|drG|d}||r||VndS|0|dEdSdS)zVVariant of itertools.takewhile except it does not discard the first non-matching tokenrrN)rR _fill_bufferrX)rT predicatebufferrs r takewhilezBufferingIterator.takewhiles ))!,, q Ay||      ))!,,     rc|||j}t||kr$t|}|n6g}|r2|r0|||dz}|r|0|SNr#)r^rRr)r<r=r*rX)rTcountr`rets r consume_manyzBufferingIterator.consume_manys %    v;;%  v,,C LLNNNNC U  6>>++,,,  U  rc*t|jSr)r<rRr[s r peek_bufferzBufferingIterator.peek_buffersDL!!!rNc|j}d}|||kre|t|kr-||dz|t|krdS||}||r|dzS|dz }|_||kedS)Nrrr#)rRr)r^)rTr_limitr`irs r peek_findzBufferingIterator.peek_finds  mq5yyCKK!!!a%(((F ##4q Ay|| 1u FAmq5yytrc"|jsut|j|kr] |jt |jn#t $r d|_YnwxYwt|j|k]t|jS)NT)rSr)rRr*rZrOrYbool)rTnumbers rr^zBufferingIterator._fill_buffers} dl##f,,L''T\(:(:;;;;$$(DMEdl##f,, DL!!!s,AA"!A"c,|dSrc)peek_atr[s rpeekzBufferingIterator.peeks||Arc||t|j|kr|j|dz ndSrc)r^r)rR)rT tokens_aheads rrqzBufferingIterator.peek_atsB ,'''14T\1B1Bl1R1Rt|L1,--X\\rc|||j}t||krt|}n*|r&g}|D] }|||dz}|sn!ng}|Src)r^rRr)r<r*)rTror`rers r peek_manyzBufferingIterator.peek_manys &!!! v;;& v,,CC  C   1 ! EC rr) r,rJrKrVr\rarfrhrlr^rrrqrvrrrrMrMs """      """ $ " " "]]] rrMc#,K|t|}d}|D]}} td|}|D]}|t|jz }n7#t$r*td|}|t|jz }YnwxYw|V~||krx||kr9t jd|||}t|t jd|||}t|dS) zOFlatten a parser's output into tokens and verify it covers the entire line/textNrrrz Value parser did not fully cover the entire line with tokens ( missing range {covered}..{content_len}). Occurred when parsing "{content}" )covered content_lenlinez Value parser emitted tokens for more text than was present? Should have emitted {content_len} characters, got {covered}. Occurred when parsing "{content}" )rxrycontent) r)r iter_tokenstextAttributeErrortextwrapdedentformat ValueError)r{rUryrxtoken_or_elementr?r@msgs rlen_check_iteratorrsd 'll G"   +/+;<<HHJJF   + +3uz??* +  ' ' '(899E s5: &GGG ' + [ /#[wOO S// !o [RYZZ oos"A1B Br)$rPcollections.abcr'sysrabcrtypingrrrrrr r r r r debian._utilrdebian._deb822_repro.typesrrr_combine_parts_ret_type ImportErrorr$rdebian._deb822_repro.tokensrr8rE version_inforIrMrrrrrs @@@@@@@@@@& %*+ ,-~q()* +M >DDD 8::::::777777 !"2A2A2A2A2Ap*.!!!!!Hv)o6q9     +/":GAJ   ccccc/2GAJcccP$(""""""sAA,, A98A9