L iBBdZddlZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z dZ ejdZejj Zejj$ZGddeZd Zdd Zd Zdd ZGd deZeeZdZdZdZy)zv Decorator module, see https://github.com/micheles/decorator/blob/master/docs/documentation.md for the documentation. N)_GeneratorContextManager)getfullargspeciscoroutinefunctionisgeneratorfunctionz5.2.1z\s*def\s*([_\w][_\w\d]*)\s*\(czeZdZdZej ZdxZxZxZ xZ xZ Z ddZ dZd dZe d dZy) FunctionMakerz An object with the ability to create functions with a given signature. It has attributes name, doc, module, signature, defaults, dict and methods update and make. Nc R||_|r?|j|_|jdk(rd|_|j|_|j |_tj|st|tjrt|}t|di|_dD]} t|| t|| t!|j"D]\} } t|d| z| t%|j"} t%|j"} |j&r=| j)d|j&z| j)d|j&zn|j*r| j)d|j*D],} | j)d| z| j)| d| .|j,r<| j)d |j,z| j)d |j,zd j/| |_d j/| |_|j2j5|_|r||_|||_|r||_|r||_|r||_|r||_t;|d sJt;|d st=d |zy)Nz_lambda___annotations__)argsvarargsvarkwdefaults kwonlyargskwonlydefaultszarg%d*z%s=None=z**, name signaturez%You are decorating a non function: %s)shortsignature__name__r__doc__doc __module__moduleinspect isroutine isinstance functoolspartialrgetattr annotationssetattr enumerater listrappendrrjoinr__dict__copydictrhasattr TypeError)selffuncrrrrrfuncdictargspecaiargallargs allshortargss O/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/decorator.py__init__zFunctionMaker.__init__As;'  DIyyJ&& ||DH//DK  &*T9;L;L*M(.#*41BB#G ,:AD!WWa%89:( 24FAsD'A+s34tyy/#DII <<NN3#56 ''dll(:;__NN3':ANN9q=1 ''1a(89:::NN4$**#45 ''tzz(9:!%7!3&*ii &=# MM..0 DI  &DN $DM DH  DK  DItV$$$t[)CdJK K*c |j|_t|dd|_t|di|_|j |_|jxsd|_t|dd|_ tjd}|jjdd}t|d||_|jj!|y#t$rd}Y;wxYw) zD Update the signature of func with the data in self rNr,r$r?r)rrr#rr*r __defaults__r__kwdefaults__r sys _getframe f_globalsgetAttributeErrorrupdate)r/r0kwframe callermodules r8rEzFunctionMaker.updateus  tUD1 fb1  MM"119T&t]DA @MM!$E!??..z3?L!$,? R  L s/C CCc |t|z}|xsi}tj|}|td|z|j d}t |g|j jdDcgc]}|jdc}z} | D]} | dvst| d||jds|dz }dt|jz} t|| d } t| |||} |r||d <|j&| fi|| Scc}w#t$r8t!d t"j$ t!|t"j$ wxYw) zT Make a new function from a given template and update the signature z not a valid function template %s,z *)_func__call_z is overridden in  zsinglezError in generated code:)file __source__)varsDEFsearch SyntaxErrorgroupsetrsplitstrip NameErrorendswithnext_compile_countcompileexec Exceptionprintr@stderrrE)r/ src_templevaldict addsourceattrssrcmorr5namesnfilenamecoder0s r8makezFunctionMaker.makesd$t*$>r ZZ_ :ACGH Hxx{TF"1177<>#ciio>>? FA((Q DEE F||D! 4KC ($t/B/B*CC 3(3D x ~ "%E,  D"E" 1>   ,3:: > #CJJ '  s/D DAEc t|tr+|jjdd\} } | dd} d} nd} d} |} || | | |||} dj d|j D}|j d}|r!t|rd|zjd d }nd |z}| j|||fi|S) z Create a function from the strings name, signature and body. evaldict is the evaluation dictionary. If addsource is true an attribute __source__ is added to the result. The attributes attrs are added, if any. (rJNrNc3&K|] }d|z yw)z Nr ).0lines r8 z'FunctionMaker.create..sFD&4-FsrMz#async def %(name)s(%(signature)s): returnz return awaitzdef %(name)s(%(signature)s): ) r strrYrXr) splitlinesrCrreplacerm)clsobjbodyrdrrrrerfrrestrr0r/ibodycallers r8createzFunctionMaker.creates c3 **32JD$Sb IDDID4y(C@ FDOO4EFFh' )&1:UBKK.*D4e;Dtyyx.funs;tR-b= ="== ==s %/-/c?bKst||\}}g|zi|D]}|ywrr)r rFresr~rr0rrs r8rzdecorate..funsCtR-bd;ftm;;   s,/cFst||\}}g|zi|Srrrs r8rzdecorate..funs1tR-b$7&4-7B7 7r:noname)rrr r!r"update_wrapperr0rrrr __wrapped__ __signature__rr>rDr?r rr*rE)r0r~rrrrs```` @r8decoraters   D !C$ ))*''dii86" > > V $    8 8 ==CL,,CKCOC((C ,, !00 "22 "}}   DMM* J-                 " !"   J sl E E.E)E8F$%F% EE E&%E&) E54E58 FFF"!F"% F21F2cfd}|S)z A version of "decorator" implemented via "exec" and not via the Signature object. Use this if you are want to preserve the `.__code__` object properties (https://github.com/micheles/decorator/issues/129). cbtj|dt|||jS)Nz)return _call_(_func_, %(shortsignature)s))rMrL)rr)rrr,r)r0r~s r8deczdecoratorx..decs6##  7 t ,4+<+< $> >r:r )r~rs` r8 decoratorxrs > Jr:c|t|dStj}|jj Dcgc]}|j t us|c}dfd }|j|_j|_ j|_ |_ j|_ tdd|_|jj!j|Scc}w)zG decorator(caller) converts a caller function into a decorator Nr ct|dz}|tfd|dDz|fdSt|S)NrJc3K|]<}|jtur(j|j|j>ywr)defaultEMPTYrCr)rrprFs r8rtz)decorator..dec..*s89"#!"%!7!ffQVVQYY79sAAc t|Srr)r0r~rrs r8z(decorator..dec...svvx Hr:)lentupler)r0r rFnarr~ dec_paramsrs ` @r8rzdecorator..dec(sR Y]9'1"#999 <H HD&&(; ;r:) parametersr?r)rrrrvalueskindPOSrxrrrrrr#r?r*rE)r~_funcrrrrrs` ` @r8 decoratorrs vr844   F #C ^^224F# !FJ< z :C??CL..CKCO**C )94@CLL( J%Gs C6C6ceZdZdZdZy)ContextManagerc4tj||||yr)rr9)r/gr3ks r8r9zContextManager.__init__?s ))$1a8r:c&fd}t||S)Ncjjgjij5||i|cdddS#1swYyxYwr) __class__r0r kwds)fr3rr/s r8r~z'ContextManager.__call__..callerCsG CDIICC "!zqz " " "s AAr)r/r0r~s` r8__call__zContextManager.__call__Bs "f%%r:N)rrrr9rr r:r8rr>s 9&r:rct|Sr)_contextmanager)r0s r8contextmanagerrLs 4  r:cd}t|D])\}}t||rd}nt||s#|||<d}+|r|j|yy)z_ Append ``a`` to the list of the virtual ancestors, unless it is already included. TFN)r& issubclassr()r3 vancestorsaddjvas r8r(r(Ssc C:&2 b! C  a JqMC  ! r:csJdddjztjdffd fd}dz|_|S)zr Factory of decorators turning a function into a generic function dispatching on the given arguments. zNo dispatch args passedz(%s,)rc|t|tr#tdtt||fzy)z5Make sure one passes the expected number of argumentszExpected %d arguments, got %d%sN)rr.) argumentswrongmsg dispatch_argss r8checkzdispatch_on..checkmsF Y]!3 4= /YEFG G 5r:c ttj}t |kstd zi fdfdfd}fd}fd}tj d zt ||| S) z4Decorator turning a function into a generic functionzUnknown dispatch arguments %sc.|ttDcgc]}g}} D]D}t|||D]2\}}}t||s||j vs't ||4F|Dcgc] }t |c}Scc}wcc}w)zU Get a list of sets of virtual ancestors for the given types )rangerziprmror(rW) types_rastypes_ttype_rarrtypemaps r8rz5dispatch_on..gen_func_dec..vancestors}s %L$S%789!29C9! *$'vs$;*LAub!!U+QUUW0Dub)* *'**CG* * : +s B 8Bc(|g}t||D]t\}}t|}|dkDrtd|d||dk(r%|\}td||fij dd}n|j }|j |ddv|S)zG Get a list of virtual MROs, one for each type rJzAmbiguous dispatch for z: rNrp)rr RuntimeErrortyperr() rlistsrvasn_vasrrrrs r8 ancestorsz4dispatch_on..gen_func_dec..ancestorss %LEeZ%78 '3C19&;.gen_func_dec..register..decs5nQ',,hkk6AJJ;NO!"r:r )rrrrs` r8registerz3dispatch_on..gen_func_dec..registers %L Jr:c|g}tj|D]#}|jtd|D%|S)zI An utility to introspect the dispatch algorithm c34K|]}|jywr)r)rrr3s r8rtzKdispatch_on..gen_func_dec..dispatch_info..s : :s)rproductr(r)rlstancsrrs r8 dispatch_infoz8dispatch_on..gen_func_dec..dispatch_infosL %LC!))9e+<= < 5 :T ::; <Jr:ctd|D} |}||i|S#t$rYnwxYwtj|}t ||D]} j |}|||i|cS|i|S)Nc32K|]}t|ywr)r)rrr5s r8rtzGdispatch_on..gen_func_dec.._dispatch..s=$s)=s)rKeyErrorrrr\rC) rr rFrr combinationsrrr0rs r8 _dispatchz4dispatch_on..gen_func_dec.._dispatchs=}==E &EN$~"~%  %,,i.?@L  & *KK'=d>b>) * $$ $s " ..z#return _f_(%s, %%(shortsignature)s))_f_)rrrrrrr)rWrr rZrrr,) r0argsetrrrrrrrr dispatch_strs ` @@@r8 gen_func_decz!dispatch_on..gen_func_decss^D)../=!V+;lJK K + &   %$## 7,F Y (D i'T $; ;r: dispatch_on)r)rner)rrrrs` @@r8rresQ 333=TYY}55L'{{G U;n*L8L r:)r Fr)rrer@rrrr! contextlibrrrr __version__r^rS ParameterPOSITIONAL_OR_KEYWORDremptyrobjectrrrrrrrrr(rr r:r8rs<  /LL bjj12 --Q=FQ=h:z B&-&N+!$fr: