§
    'ê[fN!  ã                   óÆ   — d Z dZg d¢ZddlZej        dd…         Zd„ ej        D ¦   «         e_        ddlZee_        d„ Zd„ Zdd„Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zed„ ¦   «         ZdS )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é    Nc                 ó8   — g | ]}|¯d t          |¦  «        v¯|‘ŒS )Únltk)Ústr)Ú.0Úps     úC/var/www/piapp/venv/lib/python3.11/site-packages/nltk/decorators.pyú
<listcomp>r      s-   € Ð>Ð>Ð>�! 1Ð>¨µs¸1±v´vÐ)=Ð)=ˆAÐ)=Ð)=Ð)=ó    c                 óp  — t          | ¦  «        dd…                              d¦  «        }t          |¦  «        D ]h\  }}|                     d¦  «        dk    r3|d|                     d¦  «        …                              ¦   «         ||<   ŒQ|                     ¦   «         ||<   Œid                     |¦  «        S )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, )r   ÚsplitÚ	enumerateÚcountÚindexÚstripÚjoin)Ú	signatureÚlistsignatureÚcounterÚparams       r   Ú__legacysignaturer      s®   € õ ˜	‘N”N 1 R 4Ô(×.Ò.¨sÑ3Ô3€MÝ# MÑ2Ô2ð 3ð 3‰ˆ�Ø�;Š;�sÑÔ˜aÒÐØ%*¨1¨u¯{ª{¸3Ñ/?Ô/?Ð+?Ô%@×%FÒ%FÑ%HÔ%HˆM˜'Ñ"Ð"à%*§[¢[¡]¤]ˆM˜'Ñ"Ð"Ø�9Š9�]Ñ#Ô#Ð#r   c                 ó  — t          j        | ¦  «        st          j        | ¦  «        sJ ‚t          j        | ¦  «        }|dd…         \  }}}t	          |¦  «        }|r|                     |¦  «         |r|                     |¦  «         t          j        | ¦  «        }t          |¦  «        }t          | d¦  «        r| j	        }| j
        }	n| j        }| j        }	t          | j        |||| j        | j        | j        | j        |	|¬¦
  «
        S )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¸Ñ%=Ô%=Ð=Ð=Ð=ÝÔ$ TÑ*Ô*€GØ")¨"¨1¨"¤+Ñ€GˆW�iÝ�G‰}Œ}€HØð !Ø�Š˜Ñ Ô Ð Øð #Ø�Š˜	Ñ"Ô"Ð"ÝÔ% dÑ+Ô+€Må! -Ñ0Ô0€Iõ ˆt�]Ñ#Ô#ð %ØÔ#ˆØÔ#ˆˆàÔ$ˆØÔ$ˆåØŒ]ØØØ#ØÔ"ØŒLØŒØŒ]ØØðñ ô ð r   c                 óÞ   — |pt          |¦  «        }|d         | _        |d         | _        |d         | _        | j                             |d         ¦  «         |d         | _        || _        | S )z akin to functools.update_wrapperr!   r%   r&   r'   r$   )r   r4   r6   r7   r8   Úupdater5   Úundecorated)ÚwrapperÚmodelÚinfodicts      r   Úupdate_wrapperrF   l   sm   € àÐ)�7 5™>œ>€HØ Ô'€GÔØ˜u”o€G„OØ! (Ô+€GÔØÔ×Ò˜H VÔ,Ñ-Ô-Ð-Ø# JÔ/€GÔØ€GÔØ€Nr   c                 óà   — t          |t          ¦  «        r|}nt          |¦  «        }d|d         vs
J d¦   «         ‚d|z  }t          |t          | ¬¦  «        ¦  «        }t	          |||¦  «        S )aA  
    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))rH   )Ú
isinstancer'   r   ÚevalrF   )rC   rD   rE   ÚsrcÚfuncopys        r   r   r   x   s   € õ �%�ÑÔð "Øˆˆå˜5‘>”>ˆà˜8 JÔ/Ð/Ð/Ð/Ø1ñ 0Ô/Ð/à
:¸XÑ
E€CÝ�3� wÐ/Ñ/Ô/Ñ0Ô0€GÝ˜' 5¨(Ñ3Ô3Ð3r   c                 ó.   ‡ ‡— t          ˆˆ fd„‰¦  «        S )Nc                  ó&   •—  ‰j         ‰g| ¢R i |¤ŽS ©N)Úcall)ÚaÚkr9   Úselfs     €€r   ú<lambda>z__call__.<locals>.<lambda>Ž   s#   ø€  y t¤y°Ð'?¸Ð'?Ð'?Ð'?¸QÐ'?Ð'?€ r   )r   )rS   r9   s   ``r   Ú__call__rU   �   s!   øø€ ÝÐ?Ð?Ð?Ð?Ð?ÀÑFÔFÐFr   c                 ó¢   — t          t          | ¦  «        ¦  «        }d|v rt          d¦  «        ‚d|vrt          d¦  «        ‚t          | _        | S )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.
    rU   z=You cannot decorate a class with a nontrivial __call__ methodrP   z2You cannot decorate a class without a .call method)ÚsetÚdirÚ	TypeErrorrU   )ÚclsÚattrss     r   Údecorator_factoryr\   ‘   s]   € õ •�C‘”‰MŒM€EØ�UÐÐÝØNñ
ô 
ð 	
ð �UÐÐÝÐOÑPÔPÐPÝ€C„LØ€Jr   c                 ót   ‡ — t          j        ‰ ¦  «        rt          ‰ ¦  «        S ˆ fd„}t          |‰ ¦  «        S )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                 óÀ   •— t          | ¦  «        }|d         }d|v sd|v r
J d¦   «         ‚d|z  }t          |t          | ‰¬¦  «        ¦  «        }t          || |¦  «        S )Nr"   Ú_call_Ú_func_z2You cannot use _call_ or _func_ as argument names!z3lambda %(signature)s: _call_(_func_, %(signature)s))r`   r_   )r   rJ   r'   rF   )r9   rE   r"   rK   Údec_funcÚcallers        €r   Ú
_decoratorzdecorator.<locals>._decoratorÄ   sv   ø€ Ý˜4‘=”=ˆØ˜JÔ'ˆà˜Ð Ð  H°Ð$8Ð$8Ð$8Ø?ñ %9Ô$8Ð$8àCÀhÑNˆå˜�T¨°fÐ=Ñ=Ô=Ñ>Ô>ˆÝ˜h¨¨hÑ7Ô7Ð7r   )r*   Úisclassr\   rF   )rb   rc   s   ` r   r   r   £   sP   ø€ õ< „�vÑÔð )Ý  Ñ(Ô(Ð(ð	8ð 	8ð 	8ð 	8ð 	8õ ˜* fÑ-Ô-Ð-r   c                 ó~   — 	 t          | |¦  «        S # t          $ r   |¦   «         }t          | ||¦  «         |cY S w xY w)z'Similar to .setdefault in dictionaries.)ÚgetattrÚAttributeErrorÚsetattr)Úobjr!   Údefault_thunkÚdefaults       r   Úgetattr_rl   Ò   sX   € ðÝ�s˜DÑ!Ô!Ð!øÝð ð ð Ø�-‘/”/ˆÝ��T˜7Ñ#Ô#Ð#Øˆˆˆðøøøs   ‚ ’'<»<c                 ó^   — t          | dt          ¦  «        }||v r||         S  | |Ž }|||<   |S )NÚmemoize_dic)rl   r'   )r9   ÚargsÚdicÚresults       r   Úmemoizerr   Ü   s?   € å
�4˜­Ñ
-Ô
-€Càˆs€{€{Ø�4ŒyÐØˆT�4ˆ[€FØ€Cˆ�IØ€Mr   rO   )r6   Ú__docformat__Ú__all__ÚsysÚpathÚOLD_SYS_PATHr*   r   r   rF   r   rU   r\   r   rl   rr   © r   r   ú<module>ry      s  ððð ð &€ð 2Ð
1Ð
1€à 
€
€
€
ð Œx˜˜˜Œ{€Ø>Ð>�s”xÐ>Ñ>Ô>€„Ø €€€à€„ð$ð $ð $ð=ð =ð =ð@	ð 	ð 	ð 	ð4ð 4ð 4ð*Gð Gð Gðð ð ð$,.ð ,.ð ,.ð^ð ð ð ðð ñ „ðð ð r   