B
    /‹d’
  ã               @   sž   d Z ddlZddlZddlZejjZejjdk	r<eejj7 Ze d 	e 
e¡¡¡Z[dd„ Zdd„ Zdd	„ ZG d
d„ deƒZdd„ Zdd„ ZG dd„ dƒZdS )zC A universal module with functions / classes without dependencies. é    Nz (?:\.[^{0}]+|[{0}]__init__\.py)$c                s   ‡ fdd„}|S )Nc                 s   t ˆ | |ŽƒS )N)Úlist)ÚargsÚkwargs)Úfunc© úa/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/jedi/inference/utils.pyÚwrapper   s    zto_list.<locals>.wrapperr   )r   r   r   )r   r   Úto_list   s    r	   c                s   ‡ fdd„}|S )Nc                 s   t ˆ | |ŽƒS )N)Útuple)r   r   )r   r   r   r      s    zto_tuple.<locals>.wrapperr   )r   r   r   )r   r   Úto_tuple   s    r   c             C   s   t dd„ | D ƒƒS )z5Turns a two dimensional array into a one dimensional.c             s   s   | ]}|D ]
}|V  q
qd S )Nr   )Ú.0ÚtypesÚtypr   r   r   ú	<genexpr>   s    zunite.<locals>.<genexpr>)Úset)Úiterabler   r   r   Úunite   s    r   c               @   s   e Zd ZdZdS )ÚUncaughtAttributeErrora˜  
    Important, because `__getattr__` and `hasattr` catch AttributeErrors
    implicitly. This is really evil (mainly because of `__getattr__`).
    Therefore this class originally had to be derived from `BaseException`
    instead of `Exception`.  But because I removed relevant `hasattr` from
    the code base, we can now switch back to `Exception`.

    :param base: return values of sys.exc_info().
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r      s   	r   c             C   s   t t| ƒƒS )N)ÚpropertyÚreraise_uncaught)r   r   r   r   Úsafe_property+   s    r   c                s   t  ˆ ¡‡ fdd„ƒ}|S )a*  
    Re-throw uncaught `AttributeError`.

    Usage:  Put ``@rethrow_uncaught`` in front of the function
    which does **not** suppose to raise `AttributeError`.

    AttributeError is easily get caught by `hasattr` and another
    ``except AttributeError`` clause.  This becomes problem when you use
    a lot of "dynamic" attributes (e.g., using ``@property``) because you
    can't distinguish if the property does not exist for real or some code
    inside of the "dynamic" attribute through that error.  In a well
    written code, such error should not exist but getting there is very
    difficult.  This decorator is to help us getting there by changing
    `AttributeError` to `UncaughtAttributeError` to avoid unexpected catch.
    This helps us noticing bugs earlier and facilitates debugging.
    c           
      s<   y
ˆ | |ŽS  t k
r6 } zt|ƒ|‚W d d }~X Y nX d S )N)ÚAttributeErrorr   )r   ÚkwdsÚe)r   r   r   r   @   s    
z!reraise_uncaught.<locals>.wrapper)Ú	functoolsÚwraps)r   r   r   )r   r   r   /   s    r   c               @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚPushBackIteratorc             C   s   g | _ || _d | _d S )N)ÚpushesÚiteratorÚcurrent)Úselfr"   r   r   r   Ú__init__J   s    zPushBackIterator.__init__c             C   s   | j  |¡ d S )N)r!   Úappend)r$   Úvaluer   r   r   Ú	push_backO   s    zPushBackIterator.push_backc             C   s   | S )Nr   )r$   r   r   r   Ú__iter__R   s    zPushBackIterator.__iter__c             C   s&   | j r| j  ¡ | _nt| jƒ| _| jS )N)r!   Úpopr#   Únextr"   )r$   r   r   r   Ú__next__U   s    zPushBackIterator.__next__N)r   r   r   r%   r(   r)   r,   r   r   r   r   r    I   s   r    )r   r   ÚreÚosÚpathÚsepZ_sepÚaltsepÚcompileÚformatÚescapeZ_path_rer	   r   r   Ú	Exceptionr   r   r   r    r   r   r   r   Ú<module>   s   