
    cm                     `    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
dS )    Nc                 *     d j         z    fd}|S )z6A decorator that caches the return value of a function_c           	      z    t          |           st          |  | g|R i |           t          |           S N)hasattrsetattrgetattr)selfargskwdsfuncnames      8lib/python3.11/site-packages/rope/base/utils/__init__.py_wrapperzsaveit.<locals>._wrapper
   sQ    tT"" 	;D$T 9D 9 9 9D 9 9:::tT"""    __name__)r   r   r   s   ` @r   saveitr      s7     D# # # # # #
 Or   c                       fd}|S )zDA decorator that returns the return value of `default` in recursionsc                 .     d j         z   fd}|S )Nz_calling_%s_c                     t          | d          r
             S t          | d           	  | g|R 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   s    tT5)) !wyy D$%%%+tD04000400dE****dE****s   A 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 d S w xY wr   r   )r   r   exception_classr   s     r   r   z5ignore_exception.<locals>._decorator.<locals>.newfunc-   s?    tT*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                 .     
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?   s0    M'#5!DDDD4&&&&r   r   )r   r+   r   s   `` r   r!   zdeprecated.<locals>._decorator;   s=     	9(4=8G	' 	' 	' 	' 	' 	' r   r   )r+   r!   s     r   
deprecatedr,   8   s#     ")     r   c                       fd}|S )z.A caching decorator based on parameter objectsc                 0    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 5 r   )_Cached)r   r2   sizes    @r   r   zcached.<locals>.decoratorK   s"    dD))55555r   r   )r5   r   s   ` r   cachedr6   H   s$    6 6 6 6 6 r   c                       e Zd Zd Zd ZdS )r4   c                 0    || _         g | _        || _        d S r   )r   cachecount)r
   r   r:   s      r   __init__z_Cached.__init__S   s    	



r   c                     ||f}| j         D ]\  }}||k    r|c S  | j        |i |}| j                             ||f           t          | j                   | j        k    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-(((tz??TZ' 	
1r   N)r   
__module____qualname__r;   rD   r   r   r   r4   r4   R   s2          
	 	 	 	 	r   r4   c                     t          | t                    s| S d| vr| dz  } |                     dd          \  }}t          |           t          j        |         }|rt          ||          n|S )zReturns object from string.   )
isinstancestrrsplit
__import__sysmodulesr	   )
str_or_objmod_nameobj_namemods       r   resolverT   d   s    j#&& 
* c
#**322Hhx
+h
C%-673!!!3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                            |          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        d         j                  } t	          |           t	          |                                           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]     |$$TYq\%899IIDKKMM(:(::)A,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 3 3 3 3 3 6! v)>)> {  .~//L	!TYq\5H15L  //0ABB1EEr   r   )rN   r(   r   cacheitr   r"   r,   r6   r4   rT   ri   r   r   r   <module>rk      s    



 
 
 
   (               $	7 	7 	7F F F F Fr   