ó
’›V]c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z e j j	 Z
 e j j d k	 rƒ e
 e j j 7Z
 n  e j d j e j e
 ƒ ƒ ƒ Z [
 d „  Z d „  Z d e f d „  ƒ  YZ d	 „  Z d
 „  Z d e f d „  ƒ  YZ e j d „  ƒ Z d d „ Z d S(   sC    A universal module with functions / classes without dependencies. iÿÿÿÿN(   t   reraises    (?:\.[^{0}]+|[{0}]__init__\.py)$c            s   ‡  f d †  } | S(   Nc             s   t  ˆ  |  | Ž  ƒ S(   N(   t   list(   t   argst   kwargs(   t   func(    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   wrapper   s    (    (   R   R   (    (   R   s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   to_list   s    c         C   s   t  d „  |  Dƒ ƒ S(   s5   Turns a two dimensional array into a one dimensional.c         s   s"   |  ] } | D] } | Vq q d  S(   N(    (   t   .0t   typest   typ(    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pys	   <genexpr>   s    (   t   set(   t   iterable(    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   unite   s    t   UncaughtAttributeErrorc           B   s   e  Z d  Z RS(   sè  
    Important, because `__getattr__` and `hasattr` catch AttributeErrors
    implicitly. This is really evil (mainly because of `__getattr__`).
    `hasattr` in Python 2 is even more evil, because it catches ALL exceptions.
    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().
    (   t   __name__t
   __module__t   __doc__(    (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyR      s   
c         C   s   t  t |  ƒ ƒ S(   N(   t   propertyt   reraise_uncaught(   R   (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   safe_property*   s    c            s"   t  j ˆ  ƒ ‡  f d †  ƒ } | S(   sŠ  
    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.

    .. note:: Treating StopIteration here is easy.
              Add that feature when needed.
    c             sP   y ˆ  |  | Ž  SWn8 t  k
 rK t j ƒ  } t t | d ƒ | d ƒ n Xd  S(   Ni   i   (   t   AttributeErrort   syst   exc_infoR    R   (   R   t   kwdsR   (   R   (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyR   B   s
    (   t	   functoolst   wraps(   R   R   (    (   R   s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyR   .   s    t   PushBackIteratorc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   g  |  _  | |  _ d  |  _ d  S(   N(   t   pushest   iteratort   Nonet   current(   t   selfR   (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   __init__M   s    		c         C   s   |  j  j | ƒ d  S(   N(   R   t   append(   R   t   value(    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt	   push_backR   s    c         C   s   |  S(   N(    (   R   (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   __iter__U   s    c         C   s
   |  j  ƒ  S(   s    Python 2 Compatibility (   t   __next__(   R   (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   nextX   s    c         C   s7   |  j  r |  j  j ƒ  |  _ n t |  j ƒ |  _ |  j S(   N(   R   t   popR   R&   R   (   R   (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyR%   \   s    	(   R   R   R    R#   R$   R&   R%   (    (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyR   L   s
   				c          g   s!   y	 d VWn |  k
 r n Xd S(   sŠ   
    Context manager that ignores all of the specified exceptions. This will
    be in the standard library starting with Python 3.4.
    N(    (   t
   exceptions(    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   ignoredd   s    	s       c            sm   d } x2 |  r: |  d d k r: | |  d 7} |  d  }  q	 W|  j  d ƒ } d j t ‡  f d †  | ƒ ƒ | S(   sA   This function indents a text block with a default of four spaces.t    iÿÿÿÿs   
c            s   ˆ  |  S(   N(    (   t   s(   t	   indention(    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   <lambda>w   R*   (   t   splitt   joint   map(   t   textR,   t   tempt   lines(    (   R,   s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   indent_blockp   s    (   R   R   t
   contextlibR   t   ret   ost   jedi._compatibilityR    t   patht   sept   _sept   altsepR   t   compilet   formatt   escapet   _path_reR   R   t	   ExceptionR   R   R   t   objectR   t   contextmanagerR)   R4   (    (    (    s2   lib/python2.7/site-packages/jedi/evaluate/utils.pyt   <module>   s&   !				