L idZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZmZe e j"Zd dZd dZdd Zdd Zdd Zy)z"Better tokenizing for coverage.py.) annotationsN)Iterable)env)TLineNoTSourceTokenLinesc #Kd}d}d}|D]A\}}\}}\}} } ||k7r|r|jdrd} |jdrd} ny|tjk(r7|jdr#|jdj|rd} n2d} n/tj j r|tjk(rd} | rBt|jd d d z } tjd d|| f|| d zf|| }|tjtjfvr|}tj||||f|| f| |}Dyw)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\Fz \  i)endswithtokenSTRINGrstripr PYBEHAVIORfstring_syntaxFSTRING_MIDDLElensplittokenize TokenInfoNEWLINENL) toks last_line last_lineno last_ttextttypettextslinenoscolelinenoecolltextinject_backslashccols Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/phystokens.py _phys_tokensr+sj!IKJAE6=uow ' !Y//7 $( &&t,',$ell*!**62%,,W5>>zJ,0(,1(^^22u@T@T7T',$#yt4R89A=D",, $ $(+! I ))8;;7 7J  $QVWW m6sEEct}tjtj|D]}t |tj rR|j |j|jD]'}|j |jj)otjdk\st |tjs|j |j|S)zCHelper for finding lines with soft keywords, like match/case lines.) ) setastwalkparse isinstanceMatchaddlinenocasespatternsys version_info TypeAlias)sourcesoft_key_linesnodecases r*find_soft_key_linesr@]s#&5N6*+, dCII &   t{{ +  8""4<<#6#67 8    (Zcmm-L   t{{ + , c#RKtjtjtjtj h}g}d}|j djdd}t|}t|}t|D]\}}\}} \} } } d} tjd|D]c} | dk(r |g}d}d}nM| dk(rd}nD||vrd}n>00Ue>R>R5R<<T2::3ED#d)+D$*KKsdSj'9 :;!&J$--11%>DDFrJ EJJ&((/$)  ..u5t9>/3,!$i1n$q'!*2D/3,/4,+0G(-I Y-.DE" F CM&P   s HH' H'cjtj|j}tj|S)zA helper around `tokenize.generate_tokens`. Originally this was used to cache the results, but it didn't seem to make reporting go faster, and caused issues with using too much memory. )ioStringIOreadlinerrN)textrgs r*rNrNs){{4 ))H  # #H --rAczt|jdj}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)r<rgs r*source_encodingrns5F%%d+,55H  # #H -a 00rA)r TokenInfosreturnro)r<strrpz set[TLineNo])r<rqrpr)rhrqrpro)r<bytesrprq)__doc__ __future__rr0rerUrOr9rrcollections.abcrcoveragercoverage.typesrrrror+r@rcrNrnrAr*rysX)"  $5 h(( ) CL BJ. 1rA