
    /hS                         S r Sr/ SQrSSKr\R                  SS r\R                   V s/ s H  o (       d  M  S\" U 5      ;  d  M  U PM     sn \l        SSKr\\l        S rS r	SS jr
S	 rS
 rS rS rS r\S 5       rgs  sn f )a  
Decorator module by Michele Simionato <michelesimionato@libero.it>
Copyright Michele Simionato, distributed under the terms of the BSD License (see below).
http://www.phyast.pitt.edu/~micheles/python/documentation.html

Included in NLTK for its support of a nice memoization decorator.
zrestructuredtext en)	decoratornew_wrappergetinfo    Nnltkc                     [        U 5      SS R                  S5      n[        U5       HR  u  p#UR                  S5      S:  a&  USUR	                  S5       R                  5       X'   M@  UR                  5       X'   MT     SR                  U5      $ )z
For retrocompatibility reasons, we don't use a standard Signature.
Instead, we use the string generated by this method.
Basically, from a Signature we create a string and remove the default values.
   ,=r   z, )strsplit	enumeratecountindexstripjoin)	signaturelistsignaturecounterparams       G/var/www/auris/envauris/lib/python3.13/site-packages/nltk/decorators.py__legacysignaturer      s     	N1R(..s3M#M2;;sa%*1u{{3/?%@%F%F%HM"%*[[]M"	 3
 99]##    c                 r   [         R                  " U 5      (       d  [         R                  " U 5      (       d   e[         R                  " U 5      nUSS u  p#n[	        U5      nU(       a  UR                  U5        U(       a  UR                  U5        [         R                  " U 5      n[        U5      n[        U S5      (       a  U R                  nU R                  n	OU R                  nU R                  n	[        U R                  UUUU R                  U R                   U R"                  U R$                  U	US9
$ )a  
Returns an info dictionary containing:
- name (the name of the function : str)
- argnames (the names of the arguments : list)
- defaults (the values of the default arguments : tuple)
- signature (the signature : str)
- fullsignature (the full signature : Signature)
- doc (the docstring : str)
- module (the module name : str)
- dict (the function __dict__ : str)

>>> def f(self, x=1, y=2, *args, **kw): pass

>>> info = getinfo(f)

>>> info["name"]
'f'
>>> info["argnames"]
['self', 'x', 'y', 'args', 'kw']

>>> info["defaults"]
(1, 2)

>>> info["signature"]
'self, x, y, *args, **kw'

>>> info["fullsignature"]
<Signature (self, x=1, y=2, *args, **kw)>
N   __closure__)
nameargnamesr   fullsignaturedefaultsdocmoduledictglobalsclosure)inspectismethod
isfunctiongetfullargspeclistappendr   r   hasattrr   __globals__func_closurefunc_globalsr#   __name____defaults____doc__
__module____dict__)
funcargspecregargsvarargs	varkwargsr   r   r   _closure_globalss
             r   r   r   ,   s   < D!!W%7%7%=%===$$T*G")"1+GiG}H 	"%%d+M!-0I t]######$$$$]]#""LL]] r   c                     U=(       d    [        U5      nUS   U l        US   U l        US   U l        U R                  R                  US   5        US   U l        Xl        U $ )z akin to functools.update_wrapperr   r!   r"   r#   r    )r   r0   r2   r3   r4   updater1   undecorated)wrappermodelinfodicts      r   update_wrapperrB   l   sf    )75>H'GuoGO!(+GHV,-#J/GNr   c                     [        U[        5      (       a  UnO[        U5      nSUS   ;  d   S5       eSU-  n[        U[        U S95      n[	        XAU5      $ )a)  
An improvement over functools.update_wrapper. The wrapper is a generic
callable object. It works by generating a copy of the wrapper with the
right signature and by updating the copy, not the original.
Moreovoer, 'model' can be a dictionary with keys 'name', 'doc', 'module',
'dict', 'defaults'.
	_wrapper_r   z("_wrapper_" is a reserved argument name!z.lambda %(signature)s: _wrapper_(%(signature)s))rD   )
isinstancer#   r   evalrB   )r?   r@   rA   srcfuncopys        r   r   r   x   sd     %5>8J//212/
:X
EC3w/0G'(33r   c                 (   ^ ^ [        UU 4S jT5      $ )Nc                  0   > TR                   " T/U Q70 UD6$ N)call)akr5   selfs     r   <lambda>__call__.<locals>.<lambda>   s    tyy'?'?Q'?r   )r   )rO   r5   s   ``r   __call__rR      s    ?FFr   c                     [        [        U 5      5      nSU;   a  [        S5      eSU;  a  [        S5      e[        U l        U $ )z
Take a class with a ``.caller`` method and return a callable decorator
object. It works by adding a suitable __call__ method to the class;
it raises a TypeError if the class already has a nontrivial __call__
method.
rR   z=You cannot decorate a class with a nontrivial __call__ methodrL   z2You cannot decorate a class without a .call method)setdir	TypeErrorrR   )clsattrss     r   decorator_factoryrY      sK     CMEUN
 	
 UOPPCLJr   c                 t   ^  [         R                  " T 5      (       a  [        T 5      $ U 4S jn[        UT 5      $ )a  
General purpose decorator factory: takes a caller function as
input and returns a decorator with the same attributes.
A caller function is any function like this::

 def caller(func, *args, **kw):
     # do something
     return func(*args, **kw)

Here is an example of usage:

>>> @decorator
... def chatty(f, *args, **kw):
...     print("Calling %r" % f.__name__)
...     return f(*args, **kw)

>>> chatty.__name__
'chatty'

>>> @chatty
... def f(): pass
...
>>> f()
Calling 'f'

decorator can also take in input a class with a .caller method; in this
case it converts the class into a factory of callable decorator objects.
See the documentation for an example.
c                    > [        U 5      nUS   nSU;   d  SU;   a   S5       eSU-  n[        U[        U TS95      n[        X@U5      $ )Nr   _call__func_z2You cannot use _call_ or _func_ as argument names!z3lambda %(signature)s: _call_(_func_, %(signature)s))r]   r\   )r   rF   r#   rB   )r5   rA   r   rG   dec_funccallers        r   
_decoratordecorator.<locals>._decorator   sf    4=J' H$8	@?	@ 
 DhNTf=>hh77r   )r&   isclassrY   rB   )r_   r`   s   ` r   r   r      s3    < v ((	8 *f--r   c                 d     [        X5      $ ! [         a    U" 5       n[        XU5        Us $ f = f)z'Similar to .setdefault in dictionaries.)getattrAttributeErrorsetattr)objr   default_thunkdefaults       r   getattr_rj      s7    s!! /7#s   
 //c                 L    [        U S[        5      nX;   a  X!   $ U " U6 nX2U'   U$ )Nmemoize_dic)rj   r#   )r5   argsdicresults       r   memoizerp      s2    
4
-C{y4[FIMr   rK   )r2   __docformat____all__syspathOLD_SYS_PATHr   r&   r   r   rB   r   rR   rY   r   rj   rp   )ps   0r   <module>rw      s    & 2 
 xx{xx>x!1As1v)=Ax> $=@	4*G$,.^  M ?s   
B
BB