
    Æem                     X    d dl Z d dlZd ZeZd Zd ZddZd Z G d d      Zd	 Z	d
 Z
y)    Nc                 4     d j                   z    fd}|S )z6A decorator that caches the return value of a function_c           	      b    t        |       st        |  | g|i |       t        |       S N)hasattrsetattrgetattr)selfargskwdsfuncnames      :/usr/lib/python3/dist-packages/rope/base/utils/__init__.py_wrapperzsaveit.<locals>._wrapper
   s5    tT"D$T 9D 9D 9:tT""    __name__)r   r   r   s   ` @r   saveitr      s     D#
 Or   c                       fd}|S )zDA decorator that returns the return value of `default` in recursionsc                 8     d j                   z   fd}|S )Nz_calling_%s_c                     t        | d      r        S t        | d       	  | g|i |t        | d       S # t        | d       w xY w)NFT)r	   r   )r
   r   r   defaultr   r   s      r   newfuncz5prevent_recursion.<locals>.decorator.<locals>.newfunc   sS    tT5)y D$%+D04040dE*dE*s	   = Ar   )r   r   r   r   s   ` @r   	decoratorz$prevent_recursion.<locals>.decorator   s    -	+ r    )r   r   s   ` r   prevent_recursionr      s     r   c                       fd}|S )z5A decorator that ignores `exception_class` exceptionsc                       fd}|S )Nc                  ,    	  | i |S # $ r Y y w xY wr   r   )r   r   exception_classr   s     r   r   z5ignore_exception.<locals>._decorator.<locals>.newfunc-   s*    T*T**" s    r   )r   r   r    s   ` r   
_decoratorz$ignore_exception.<locals>._decorator,   s    	 r   r   )r    r!   s   ` r   ignore_exceptionr"   )   s     r   c                     | fd}|S )z$A decorator for deprecated functionsc                 8     d j                   z   fd}|S )Nz%s is deprecatedc                  L    t        j                  t        d        | i |S )N   )
stacklevel)warningswarnDeprecationWarning)r   r   r   messages     r   r   z/deprecated.<locals>._decorator.<locals>.newfunc?   s$    MM'#5!D&&&r   r   )r   r+   r   s   `` r   r!   zdeprecated.<locals>._decorator;   s"    ?(4==8G	' r   r   )r+   r!   s     r   
deprecatedr,   8   s     ")  r   c                       fd}|S )z.A caching decorator based on parameter objectsc                 (    t        |       fdS )Nc                       | i |S r   r   )akwcached_funcs     r   <lambda>z+cached.<locals>.decorator.<locals>.<lambda>M   s    Q 5" 5 r   )_Cached)r   r2   sizes    @r   r   zcached.<locals>.decoratorK   s    dD)55r   r   )r5   r   s   ` r   cachedr6   H   s    6 r   c                       e Zd Zd Zd Zy)r4   c                 .    || _         g | _        || _        y r   )r   cachecount)r
   r   r:   s      r   __init__z_Cached.__init__S   s    	

r   c                    ||f}| j                   D ]  \  }}||k(  s|c S   | j                  |i |}| j                   j                  ||f       t        | j                         | j                  kD  r| j                   d= |S Nr   )r9   r   appendlenr:   )r
   r   r   key
cached_keycached_resultresults          r   __call__z_Cached.__call__X   s    Tl)- 	%%JS $$	% D)D)

3-(tzz?TZZ'

1r   N)r   
__module____qualname__r;   rD   r   r   r   r4   r4   R   s    
	r   r4   c                     t        | t              s| S d| vr| dz  } | j                  dd      \  }}t        |       t        j
                  |   }|rt        ||      S |S )zReturns object from string.   )
isinstancestrrsplit
__import__sysmodulesr	   )
str_or_objmod_nameobj_namemods       r   resolverT   d   se    j#&
*c
#**32Hhx
++h
C%-73!636r   c                      fd}t         j                  dk\  st        d      sj                  S  |       rj                  d   j                  nj                  d   j                  dz
  } j
                  j                  |      d   S )a  Find the line number for a function or class definition.

    `node` may be either an ast.FunctionDef, ast.AsyncFunctionDef, or ast.ClassDef

    Python 3.8 simply provides this to us, but in earlier versions the ast
    node.lineno points to the first decorator rather than the actual
    definition, so we try our best to find where the definitions are.

    This is to workaround bpo-33211 (https://bugs.python.org/issue33211)
    c                      j                   j                  j                  d   j                        } t	        |       t	        | j                               z
  }j                  d   j                  }||k  S r=   )linesget_linebodylinenor?   lstrip
col_offset)lineindent_col_offsetbody_col_offsetmodulenodes      r   is_inline_bodyz(guess_def_lineno.<locals>.is_inline_body|   s_     ||$$TYYq\%8%89IDKKM(::))A,11 ?22r   )      rY   r   rI   )rN   version_infor   rZ   rY   logical_lineslogical_line_in)r`   ra   rb   possible_def_lines   ``  r   guess_def_linenori   p   s|    3 6!v)>{{  ./		!TYYq\5H5H15L  //0AB1EEr   r   )rN   r(   r   cacheitr   r"   r,   r6   r4   rT   ri   r   r   r   <module>rk      s@    
 
 (  $	7Fr   