,(P^mdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z mZmZddlmZddlmZmZe e jZdd ZGd d ejZddZGddZejZddZdS)z"Better tokenizing for coverage.py.) annotationsN)IterableListOptionalSetTuple)env)TLineNoTSourceTokenLinestoks TokenInfosreturnc #:Kd}d}d}|D]\}}\}}\}} } ||kr|r|drd} |drd} n<|tjkr,d|vr(|dd d ddkrd} | rLt |dd d z } t jd d|| f|| d zf|V| }|t jt jfvr|}t j||||f|| f| V|}dS)aBReturn all physical tokens, even line continuations. tokenize.generate_tokens() doesn't return a token for the backslash that continues lines. This wrapper provides those tokens so that we can re-create a faithful representation of the original source. Returns the same values as generate_tokens() Nz\ T\F ri) endswithtokenSTRINGsplitlentokenize TokenInfoNEWLINENL) r last_line last_lineno last_ttextttypettextslinenoscolelinenoecolltextinject_backslashccols /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/coverage/phystokens.py _phys_tokensr-s $IKJAE''=uow ' ! ! Y//77  $( &&t,,1',$$el**u}}T1)=)=a)@)D)L)L,1(#yt44R899A=D",v $'46):! I )8;7 7 7J $QVWWWWW O''c<eZdZdZd dZejdkrd d Zd Sd S)MatchCaseFinderz$Helper for finding match/case lines.sourcestrrNoneczt|_|tj|dSN)setmatch_case_linesvisitastparse)selfr1s r,__init__zMatchCaseFinder.__init__Rs0.1ee 39V$$%%%%%r. node ast.Matchc|j|j|jD]&}|j|jj'||dS)z Invoked by ast.NodeVisitor.visitN)r7addlinenocasespattern generic_visit)r;r@cases r, visit_MatchzMatchCaseFinder.visit_MatchXse  ! % %dk 2 2 2  ? ?%))$,*=>>>>   t $ $ $ $ $r.N)r1r2rr3)r@rArr3)__name__ __module__ __qualname____doc__r<sys version_inforIr.r,r0r0PsZ..&&&&  7"" % % % % % %#"r.r0r1r2r c#@Ktjtjtjtjh}g}d}|ddd}t|}tj j rt|j }t|D]s\}}\}} \} } } d} tjd|D]G} | dkr |Vg}d}d}n0| dkrd}n&||vrd}n| r%| |kr|d d | |z zfd} tj|d d d }|tjkrt-j|rd}n}t0jdkrmtj j r\t-j|rHt7|dkrd}n*t7|dkr|ddd krd}nd}|r||vrd}||| fd}d} I|r| }u|r|Vd Sd S)aGenerate a series of lines, one for each line in `source`. Each line is a list of pairs, each pair is a token:: [('key', 'def'), ('ws', ' '), ('nam', 'hello'), ('op', '('), ... ] Each pair has a token class, and the token text. If you concatenate all the token texts, and then join them with newlines, you should have your original `source` back, with two differences: trailing white space is not preserved, and a final line with no newline is indistinguishable from a final line with a newline. rz rTz( )Frws xxNr>keyr=r)rINDENTDEDENTrrr expandtabsreplacegenerate_tokensr PYBEHAVIOR soft_keywordsr0r7r-rerappendtok_namegetlowerNAMEkeyword iskeywordrNrO issoftkeywordr)r1 ws_tokenslinecoltokgenr7r#r$sliner&_r( mark_startpartmark_end tok_classis_start_of_lines r,source_token_linesrr`sq u|U]HKHI"$D C   q ! ! ) )&$ 7 7F V $ $F ~#D*622C5A&5I5I''1umudYa HVU++# # Dt||   )## '$**KKsdSj'9 :;;;!&J$-11%>>DDFFrrJ EJ&&(//2$) )W44>7 2G ! !!DN{4((1H #'(@(J(J#K#K   !%s &A AN)rr3)rxr2rr )rJrKrLrMr<r[rPr.r,rtrtsF  8888       r.rtbytesct|dj}tj|dS)zDetermine the encoding for `source`, according to PEP 263. `source` is a byte string: the text of the program. Returns a string, the name of the encoding. Tr)iter splitlines__next__rdetect_encoding)r1r|s r,source_encodingrs8F%%d++,,5H  #H - -a 00r.)r r rr )r1r2rr )r1r~rr2)rM __future__rr9rzrdr^rNrrtypingrrrrrcoverager coverage.typesr r rr r- NodeVisitorr0rrrtr[rrPr.r,rss)(""""""  7777777777777755555555h( ) 4444n % % % % %co % % % DDDDN        8"/##3 1 1 1 1 1 1r.