bg ddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ddlmZdd lmZGd d Zd ee eeffd Zddeded ejfdZde ed e efdZdedejd eee effdZ ddededede ejd eejeeff dZdS)N) bisect_right)Iterable)Iterator)List)Optional)overload)Tuple)Unionc*eZdZdZddeddfdZdedefdZdZe de de fd Z e de ddfd Z dee e fdee dffd Z dee fd Zde fd ZddZdde ddfdZde ddfdZde dee e ffdZddZde fdZdS)SourcezvAn immutable object holding a source code fragment. When using Source(...), the source lines are deindented. Nobjreturnc6|s g|_dSt|tr|j|_dSt|ttfr t d|D|_dSt|t r)t |d|_dS t|}tj |}n$#t$rtj |}YnwxYwt |d|_dS)Nc3@K|]}|dVdS Nrstrip.0xs e/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/_code/source.py z"Source.__init__..s,!>!>Q!((4..!>!>!>!>!>!>r) lines isinstancer tuplelistdeindentstrsplit getrawcodeinspect getsource TypeError)selfr rawcodesrcs r__init__zSource.__init__s  3$&DJJJ V $ $ 3DJJJ eT] + + 3!!>!>#!>!>!>>>DJJJ S ! ! 3!#))D//22DJJJ -$S//'00 - - -',, -!#))D//22DJJJs*#CC/.C/othercZt|tstS|j|jkSN)rr NotImplementedr)r&r*s r__eq__z Source.__eq__(s)%(( "! !zU[((rkeycdSr,r&r/s r __getitem__zSource.__getitem__0 rcdSr,r1r2s rr3zSource.__getitem__4r4rct|tr |j|S|jdvrt dt }|j|j|j|_|S)N)Nz!cannot slice a Source with a step)rintrstep IndexErrorr startstop)r&r/ newsources rr3zSource.__getitem__8sb c3   :c? "xy(( !DEEEI"jSX)=>IO rc*t|jSr,)iterrr&s r__iter__zSource.__iter__BsDJrc*t|jSr,)lenrr@s r__len__zSource.__len__Es4:rcdt|}}||krI|j|s*|dz }||kr|j|*||krO|j|dz s-|dz}||kr"|j|dz -t}|j|||jdd<|S)zGReturn new Source object with trailing and leading blank lines removed.rr7N)rCrstripr )r&r;endsources rrFz Source.stripHsD sckk$*U"3"9"9";";k QJEckk$*U"3"9"9";";kEkk$*S1W"5";";"="=k 1HCEkk$*S1W"5";";"="=k*U3Y/ QQQ r indentcTt}fd|jD|_|S)z^Return a copy of the source object with all lines indented by the given indent-string.cg|]}|zSr1r1)rlinerJs r z!Source.indent..WsBBBtFTMBBBr)r r)r&rJr=s ` rrJz Source.indentSs1HH BBBBtzBBB rlinenocF||\}}|||S)zUReturn Source statement which contains the given linenumber (counted from 0).)getstatementrange)r&rOr;rGs r getstatementzSource.getstatementZs)++F33 sE#Ircd|cxkrt|ksntdt||\}}}||fS)zmReturn (start, end) tuple which spans the minimal statement region which containing the given lineno.rzlineno out of range)rCr:getstatementrange_ast)r&rOastr;rGs rrQzSource.getstatementrange`sWV''''c$ii''''233 3/==UCczrc^t}t|j|jdd<|S)z&Return a new Source object deindented.N)r rr)r&r=s rrzSource.deindenths+HH %dj11 rc6d|jSNr)joinrr@s r__str__zSource.__str__nsyy$$$rr,)rr )rI)__name__ __module__ __qualname____doc__objectr)boolr.__hash__rr8r r3slicer rrArDrFrJrRr rQrrZr1rrr r s 33F3d3333")F)t)))) H  s s   X  u    X uS%Z0U3=5I (3-        Sx38 c3h %%%%%%%rr rc tj|\}}n#t$rYdSwxYwt}d|D|_||fS)N)Nc6g|]}|Sr1r)rrMs rrNzfindsource..}s :::dDKKMM:::r)r# findsource Exceptionr r)r sourcelinesrOrHs rrfrfwsh%055 VV xx XXF::k:::FL 6>s  ((Tr trycallc |jS#t$rYnwxYw|r9t|dd}|r&t|tst |dSt d|)z&Return code object for given function.__call__NF)rizcould not get code object for )__code__AttributeErrorgetattrrtyper"r%)r ricalls rr"r"s |      3sJ--  3 3-- 3dE222 2 .s& : :Qq4x : : : : : :rc"tSr,)next)itsrz'getstatementrange_ast..s Rr#)r warningscatch_warnings simplefilterrUparserrCrr# BlockFinderisspacestartedtokenizegenerate_tokens tokeneater EndOfBlockIndentationErrorlastrglstrip startswith) rOrHrrcontentr;rG block_findertokrMrs @rrTrTs f++ $ & & ; ;  !( + + +i6::G ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;)99JE3  {&, UQY*,, %|E215==??  : :&,uSy"9 : : : /0@0@0@0@AA . .' '--- ."$45 , , ,#e+CCC    D  |C!G$++-- ??3   t  1HCC   E3 s)+AA!$A!1$D E8 EE)T)FN)rUr#rrrtypesrbisectrtypingrrrrrr r r r8rfr_r`CodeTyper"r rASTrrTr1rrrs'  ^%^%^%^%^%^%^%^%LuXf-s23 > >F >T >U^ > > > >:HSM:d3i::::Csw5hsmAS;T<!% ,, , ,,cg  ,  37C  ,,,,,,r