Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/astroid/__pycache__/decorators.cpython-37.pyc

B

��\��@s|dZddlZddlZddlmZddlmZddlmZejdd��Z	Gdd	�d	�Z
d
d�Zejdd
��Zejdd��Z
dS)z) A few useful function/method decorators.�N)�context)�
exceptions)�utilcCsRt|dd�}|dkri|_}y||Stk
rL|||�||<}|SXdS)z>Simple decorator to cache result of method calls without args.�__cacheN)�getattrr�KeyError)�func�instance�args�kwargs�cache�result�r�C/opt/alt/python37/lib/python3.7/site-packages/astroid/decorators.py�cacheds
rc@s2eZdZdZdZdd�Zedd��Zd
dd	�ZdS)�cachedpropertya� Provides a cached property equivalent to the stacking of
    @cached and @property, but more efficient.

    After first usage, the <property_name> becomes part of the object's
    __dict__. Doing:

      del obj.<property_name> empties the cache.

    Idea taken from the pyramid_ framework and the mercurial_ project.

    .. _pyramid: http://pypi.python.org/pypi/pyramid
    .. _mercurial: http://pypi.python.org/pypi/Mercurial
    )�wrappedc
CsFy
|jWn0tk
r:}ztd|�|�Wdd}~XYnX||_dS)Nz!%s must have a __name__ attribute)�__name__�AttributeError�	TypeErrorr)�selfr�excrrr�__init__6s

 zcachedproperty.__init__cCs"t|jdd�}d|rd|ndS)N�__doc__z+<wrapped by the cachedproperty decorator>%sz
%s�)rr)r�docrrrr=szcachedproperty.__doc__NcCs*|dkr|S|�|�}t||jj|�|S)N)r�setattrr)r�instZobjtype�valrrr�__get__Ds

zcachedproperty.__get__)N)r�
__module__�__qualname__r�	__slots__r�propertyrrrrrr%s

rcCst�|�d|fdd��}|S)z�return the given infer function wrapped to handle the path

    Used to stop inference if the node has already been looked
    at for a given `InferenceContext` to prevent infinite recursion
    Nc	
{s�|dkrt��}|�|�rdSt�}|||f|�}yBx<t|�}|jjdkrR|j}n|}||kr6|V|�|�q6WWn2t	k
r�}z|j
r�|j
dSdSd}~XYnXdS)z!wrapper function handling contextNZInstancer)�
contextmodZInferenceContext�push�set�next�	__class__rZ_proxied�add�
StopIterationr
)	�noderZ_funcr�yielded�	generator�resZares�errorrrrrSs&

zpath_wrapper.<locals>.wrapped)�	functools�wraps)rrrrr�path_wrapperLsr2ccsD|||�}yt|�VWntk
r4tjVdSX|EdHdS)N)r'r*rZUninferable)rr	r
rr-rrr�yes_if_nothing_inferredps
r3c
csl|||�}yt|�VWnDtk
r\}z&|jrBtjf|jd��t�d��Wdd}~XYnX|EdHdS)Nrz3StopIteration raised without any error information.)r'r*r
rZInferenceError)rr	r
rr-r/rrr�raise_if_nothing_inferred~s
r4)rr0�wrapt�astroidrr$rrZ	decoratorrrr2r3r4rrrr�<module>
s
'$