
    ^hB                     F   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJ	r	J
r
Jr  Sr\R                  " S5      r\R                  R                   r\R                  R$                  r " S S\5      rS	 rSS
 jrS rSS jr " S S\5      r\" \5      rS rS rS rg)zv
Decorator module, see
https://github.com/micheles/decorator/blob/master/docs/documentation.md
for the documentation.
    N)_GeneratorContextManager)getfullargspeciscoroutinefunctionisgeneratorfunctionz5.2.1z\s*def\s*([_\w][_\w\d]*)\s*\(c                       \ rS rSrSr\R                  " 5       rS=r=r	=r
=r=rr  S
S jrS rSS jr\  SS j5       rS	rg)FunctionMaker4   z
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           	         X0l         U(       Ga_  UR                  U l        U R                  S:X  a  SU l        UR                  U l        UR
                  U l        [        R                  " U5      (       d   [        U[        R                  5      (       Ga  [        U5      n[        US0 5      U l        S H  n	[        X	[        X5      5        M     [!        U R"                  5       H  u  p[        U SU
-  U5        M     [%        U R"                  5      n[%        U R"                  5      nU R&                  (       a=  UR)                  SU R&                  -   5        UR)                  SU R&                  -   5        O"U R*                  (       a  UR)                  S5        U R*                   H/  n	UR)                  SU	-  5        UR)                  U	< SU	< 35        M1     U R,                  (       a<  UR)                  S	U R,                  -   5        UR)                  S	U R,                  -   5        S
R/                  U5      U l        S
R/                  U5      U l         UR2                  R5                  5       U l        U(       a  X l        Ub  X0l        U(       a  X@l        U(       a  XPl        U(       a  X`l        U(       a  Xpl        [;        U S5      (       d   e[;        U S5      (       d  [=        SU-  5      eg )Nz<lambda>_lambda___annotations__)argsvarargsvarkwdefaults
kwonlyargskwonlydefaultszarg%d*z%s=None=z**, name	signaturez%You are decorating a non function: %s)shortsignature__name__r   __doc__doc
__module__moduleinspect	isroutine
isinstance	functoolspartialr   getattrannotationssetattr	enumerater   listr   appendr   r   joinr   __dict__copydictr   hasattr	TypeError)selffuncr   r   r   r   r   funcdictargspecaiargallargsallshortargss                 C/home/james-whalen/.local/lib/python3.13/site-packages/decorator.py__init__FunctionMaker.__init__A   s$   'DIyyJ&&	||DH//DK  &&*T9;L;L*M*M(.#*41BB#G ,ADWW%89, (		2FAD'A+s3 3tyy/#DII<<NN3#56 ''dll(:;__NN3'ANN9q=1 ''1a(89 ) ::NN4$**#45 ''tzz(9:!%7!3&*ii&=# MM..0	I &N$MH K ItV$$$$t[))CdJKK *    c                    U R                   Ul        [        U SS5      Ul        [        U S0 5      Ul        U R
                  Ul        U R                  =(       d    SUl        [        U SS5      Ul	         [        R                  " S5      nUR                  R                  SS5      n[        U SU5      Ul        UR                  R!                  U5        g! [         a    Sn N<f = f)	z4
Update the signature of func with the data in self
r   Nr-   r%      r   ?r   )r   r   r$   r   r+   r   __defaults__r   __kwdefaults__r   sys	_getframe	f_globalsgetAttributeErrorr   update)r0   r1   kwframecallermodules        r9   rG   FunctionMaker.updateu   s     		tUD1fb1 MM"119T&t]DA	@MM!$E !??..z3?L!$,?R   	L	s   4C C#"C#c           	         U[        U 5      -  nU=(       d    0 n[        R                  U5      nUc  [        SU-  5      eUR	                  S5      n[        U/U R                  R                  S5       Vs/ s H  oR                  S5      PM     sn-   5      n	U	 H  n
U
S;   d  M  [        U
< SU< 35      e   UR                  S5      (       d  US-  nS[        U R                  5      -  n [        X[S	5      n[        X5        X'   nU(       a  XTS'   U R&                  " U40 UD6  U$ s  snf ! [         a2    [!        S
["        R$                  S9  [!        U["        R$                  S9  e f = f)zD
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

z<decorator-gen-%d>singlezError in generated code:)file
__source__)varsDEFsearchSyntaxErrorgroupsetr   splitstrip	NameErrorendswithnext_compile_countcompileexec	ExceptionprintrB   stderrrG   )r0   	src_templevaldict	addsourceattrssrcmor   r6   namesnfilenamecoder1   s                 r9   makeFunctionMaker.make   s]    $t*$>rZZ_:ACGHHxx{TF"1177<>< 36iio<> > ?A((Q DEE  ||D!!4KC
 ($t/B/B*CC	3(3D 
 ~"%,D"E"1>   	,3::>#CJJ'	s   5D(
-D- -<E)c                    [        U[        5      (       a*  UR                  5       R                  SS5      u  pU
SS nSnOSn	SnUnU " XXXV5      nSR	                  S UR                  5        5       5      nUR                  S5      nU(       a&  [        U5      (       a  SU-   R                  S	S
5      nOSU-   nUR                  " X#U40 UD6$ )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.
(rM   NrQ   c              3   ,   #    U  H
  nS U-   v   M     g7f)z    Nr
   ).0lines     r9   	<genexpr>'FunctionMaker.create.<locals>.<genexpr>   s     F4ED&4-4Es   rP   z#async def %(name)s(%(signature)s):
returnzreturn awaitzdef %(name)s(%(signature)s):
)
r!   strr\   r[   r*   
splitlinesrE   r   replacerp   )clsobjbodyrg   r   r   r   rh   ri   r   restr   r1   r0   ibodycallers                   r9   createFunctionMaker.create   s     c3**32JDSb	IDDID4yC@		FDOO4EFFh')&11:UBKK.*D 4e;Dyy<e<<r<   )r%   r   r-   r   r   r   r   r   )NNNNNNNNF)NNNT)r   r   __qualname____firstlineno__r   	itertoolscountr`   r   r   r   r   r   r   r:   rG   rp   classmethodr   __static_attributes__r
   r<   r9   r   r   4   si     __&N GIHDH7HUHXH
^7;@D2Lh!&"H 2604= =r<   r   c                 v    UR                   " U 0 UD6nUR                  5         UR                  UR                  4$ )z9
Fix args and kwargs to be consistent with the signature
)bindapply_defaultsr   kwargs)r   r   sigbas       r9   fixr      s6     
4	"6	"B77BIIr<   c                   ^ ^^^^ [         R                  " T 5      m[        T [        R                  5      (       a!  [        R
                  " T T R                  5      m [        T5      (       a  UUU UU4S jnO%[        T5      (       a  UUU UU4S jnO
UUU UU4S jnT R                  Ul	        T R                  Ul
        T Ul        TUl        T R                  Ul         T R                  Ul         T R                   Ul         T R"                  Ul         T R$                  Ul         T R                  Ul	         UR&                  R)                  T R&                  5        U$ ! [         a     N|f = f! [         a     Nzf = f! [         a     Nxf = f! [         a     Nvf = f! [         a    T R                  S:H     Nf = f! [         a     U$ f = f)aN  
Decorates a function/generator/coroutine using a caller.
If kwsyntax is True calling the decorated functions with keyword
syntax will pass the named arguments inside the ``kw`` dictionary,
even if such argument are positional, similarly to what functools.wraps
does. By default kwsyntax is False and the the arguments are untouched.
c                  h   >#    T(       d  [        XT5      u  pT" T/TU -   Q70 UD6I S h  vN $  N7fNr   r   rH   r   extrasr1   kwsyntaxr   s     r9   fundecorate.<locals>.fun   s6     t-=="====s   (202c               ?   l   >#    T(       d  [        XT5      u  pT" T/TU -   Q70 UD6 H  nUv   M	     g 7fr   r   )r   rH   resr   r   r1   r   r   s      r9   r   r      s9     t-d;ftm;;	 <s   14c                  L   > T(       d  [        XT5      u  pT" T/TU -   Q70 UD6$ r   r   r   s     r9   r   r      s-    t-$7&4-7B77r<   noname)r   r   r!   r"   r#   update_wrapperr1   r   r   r   r   __wrapped____signature__r   r@   rF   rA   r   r   r+   rG   )r1   r   r   r   r   r   s   ```` @r9   decorater      s    

D
!C$	))**''dii86""	> 	> 
V	$	$	 		8 	8
 ==CL,,CKCOC((C,,!00"22"}}DMM* J-          "!"  Jsl   E 0E/ E? F &F 8%F> 
E,+E,/
E<;E<?
FF
FFF;:F;>
GGc                    ^  U 4S jnU$ )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).
c           	      T   > [         R                  U S[        TU S9X R                  S9$ )Nz)return _call_(_func_, %(shortsignature)s))rP   rO   )r   r   )r   r   r-   r   )r1   r   s    r9   decdecoratorx.<locals>.dec  s4    ##7t,+<+<	 $ > 	>r<   r
   )r   r   s   ` r9   
decoratorxr     s    > Jr<   c                    ^ ^^ Ub  [        UT ST5      $ [        R                  " T 5      nUR                  R	                  5        Vs/ s H  oDR
                  [        L d  M  UPM     snmSU UU4S jjnUR                  TS9Ul        T R                  Ul	        T R                  Ul
        T Ul        T R                  Ul        [        T SS5      Ul        UR                  R!                  T R                  5        U$ s  snf )z?
decorator(caller) converts a caller function into a decorator
Nr
   c                    >^^ [        U5      S-   nU[        U4S jTUS   5       5      -   mU c  UUU4S j$ [        U TTT5      $ )NrM   c              3      >#    U  H@  nUR                   [        Ld  M  TR                  UR                  UR                   5      v   MB     g 7fr   )defaultEMPTYrE   r   )rv   prH   s     r9   rx   )decorator.<locals>.dec.<locals>.<genexpr>*  s<      9'6!!"%!7 8bffQVVQYY77'6s
   A-Ac                     > [        U TTT5      $ r   r   )r1   r   r   r   s    r9   <lambda>(decorator.<locals>.dec.<locals>.<lambda>.  s    vvx Hr<   )lentupler   )r1   r   rH   nar   r   
dec_paramsr   s     ` @r9   r   decorator.<locals>.dec(  sR    Y] 9'1"#9 9 9 <HHD&&(;;r<   )
parametersrA   r   )r   r   r   r   valueskindPOSr}   r   r   r   r   r   r$   rA   r+   rG   )r   _funcr   r   r   r   r   s   ` `   @r9   	decoratorr     s     vr844


F
#C ^^224F4#!4FJ< < z:C??CL..CKCO**C )94@CLL(J% Gs   C;!C;c                        \ rS rSrS rS rSrg)ContextManageri>  c                 2    [         R                  " XX#5        g r   )r   r:   )r0   gr4   ks       r9   r:   ContextManager.__init__?  s     ))$18r<   c                 &   ^  U 4S jn[        X5      $ )Nc                    > TR                   " TR                  /TR                  Q70 TR                  D6   U " U0 UD6sS S S 5        $ ! , (       d  f       g = fr   )	__class__r1   r   kwds)fr4   r   r0   s      r9   r   'ContextManager.__call__.<locals>.callerC  s=    		CDIICC!zqz DCCs   A
Ar   )r0   r1   r   s   `  r9   __call__ContextManager.__call__B  s    	" %%r<   r
   N)r   r   r   r   r:   r   r   r
   r<   r9   r   r   >  s    9&r<   r   c                     [        U 5      $ r   )_contextmanager)r1   s    r9   contextmanagerr   L  s    4  r<   c                     Sn[        U5       H1  u  p4[        X@5      (       a  Sn  O[        X5      (       d  M+  XU'   SnM3     U(       a  UR                  U 5        gg)zS
Append ``a`` to the list of the virtual ancestors, unless it is already
included.
TFN)r'   
issubclassr)   )r4   
vancestorsaddjvas        r9   r)   r)   S  s\    
 C:&bCaqMC ' ! r<   c                     ^ ^^ T (       d   S5       eSSR                  T 5      -  m[        R                  S4U 4S jjmUU U4S jnST-   Ul        U$ )zf
Factory of decorators turning a function into a generic function
dispatching on the given arguments.
zNo dispatch args passedz(%s,)r    c                    > U" [        U 5      [        T5      5      (       a#  [        S[        T5      [        U 5      U4-  5      eg)z5Make sure one passes the expected number of argumentszExpected %d arguments, got %d%sN)r   r/   )	argumentswrongmsgdispatch_argss      r9   checkdispatch_on.<locals>.checkm  sI    Y]!344= /YEF G G 5r<   c                   >^ ^^^ [        [        T 5      R                  5      n[        T	5      U::  d  [        ST
-  5      e0 mUU	U4S jmUU4S jmUU4S jnUU4S jnUU U4S jn[        R                  T ST
-  [        US9UT TTTUT S	9
$ )
z4Decorator turning a function into a generic functionzUnknown dispatch arguments %sc                  J  > T" U 5        [        [        T5      5       Vs/ s H  n/ PM     nnT	 HK  n[        XU5       H8  u  pEn[        XE5      (       d  M  XTR	                  5       ;  d  M-  [        XV5        M:     MM     U Vs/ s H  n[        U5      PM     sn$ s  snf s  snf )z=
Get a list of sets of virtual ancestors for the given types
)ranger   zipr   mror)   rZ   )
types_rastypes_ttype_rar   r   typemaps
          r9   r   5dispatch_on.<locals>.gen_func_dec.<locals>.vancestors}  s     %L$S%7898!28C9!$'s$;LAb!!++UUW0Du) %< " '**cCGc** :
 +s   BB c                  0  > T" U 5        / n[        U T" U 6 5       Hw  u  p#[        U5      nUS:  a  [        SU< SU< 35      eUS:X  a$  Uu  n[        SX%40 5      R	                  5       SS nOUR	                  5       nUR                  USS 5        My     U$ )z/
Get a list of virtual MROs, one for each type
rM   zAmbiguous dispatch for z: r   Nrt   )r   r   RuntimeErrortyper   r)   )	r   listsr   vasn_vasr   r   r   r   s	          r9   	ancestors4dispatch_on.<locals>.gen_func_dec.<locals>.ancestors  s     %LEeZ%78C19&;<cBD DaZCBsQGR0446qr:C%%'CS"X& 9 Lr<   c                  *   >^  T" T 5        UUU 4S jnU$ )z=
Decorator to register an implementation for the given types
c                    > T" [        U 5      R                  [        R                  SU R                  -   5        U TT'   U $ )Nz in )r   r   operatorltr   )r   r   r   r   s    r9   r   @dispatch_on.<locals>.gen_func_dec.<locals>.register.<locals>.dec  s5    nQ',,hkk6AJJ;NO!"r<   r
   )r   r   r   r   s   ` r9   register3dispatch_on.<locals>.gen_func_dec.<locals>.register  s     %L Jr<   c                     > T" U 5        / n[         R                  " T" U 6 6  H$  nUR                  [        S U 5       5      5        M&     U$ )z1
An utility to introspect the dispatch algorithm
c              3   8   #    U  H  oR                   v   M     g 7fr   )r   )rv   r4   s     r9   rx   Kdispatch_on.<locals>.gen_func_dec.<locals>.dispatch_info.<locals>.<genexpr>  s      :TT   )r   productr)   r   )r   lstancsr   r   s      r9   dispatch_info8dispatch_on.<locals>.gen_func_dec.<locals>.dispatch_info  sG     %LC!))9e+<=

5 :T ::; >Jr<   c                   > [        S U  5       5      n T	U   nU" U0 UD6$ ! [         a     Of = f[        R                  " T" U6 6 n[	        U5        U H!  nT	R                  U5      nUc  M  U" U0 UD6s  $    T" U0 UD6$ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr   )r   )rv   r6   s     r9   rx   Gdispatch_on.<locals>.gen_func_dec.<locals>._dispatch.<locals>.<genexpr>  s     =}$s))}r   )r   KeyErrorr   r  r_   rE   )
r   r   rH   r   r   combinationsr   r   r1   r   s
          r9   	_dispatch4dispatch_on.<locals>.gen_func_dec.<locals>._dispatch  s    =}==E&EN $~"~%   %,,i.?@L&KK'=d>b>) ' $$$s   " 
//z#return _f_(%s, %%(shortsignature)s))_f_)r   r   r   r   r   r  r   )rZ   r   r   r]   r   r   r-   )r1   argsetr   r  r  r   r   r   r   r   dispatch_strs   `    @@@r9   gen_func_dec!dispatch_on.<locals>.gen_func_decs  s     ^D)../=!V+;lJKK
	+	&
			%$ ##7,FY(D
i'T	 $ ; 	;r<   dispatch_on)r*   r   ner   )r   r  r   r  s   ` @@r9   r  r  e  sQ    
 333=TYY}55L'{{ GU;n *L8Lr<   )r
   Fr   )r   rerB   r   r   r   r"   
contextlibr   r   r   r   __version__ra   rV   	ParameterPOSITIONAL_OR_KEYWORDr   emptyr   objectr   r   r   r   r   r   r   r   r)   r  r
   r<   r9   <module>r     s   <
 
 
     / L Ljj12--Q=F Q=h:zB&- & N+!$fr<   