
     h                         d Z ddlmZmZmZ ddlZ ej                  e      Zddl	m
Z
mZ ddlZddlmZ ddlmZ g dZ G d d	e      Z G d
 de      Zd Z G d de      Z	 	 	 ddZ	 	 ddZy)z7
passlib.utils.decor -- helper decorators & properties
    )absolute_importdivisionprint_functionN)wrapsupdate_wrapper)warn)PY3)classpropertyhybrid_methodmemoize_single_valuememoized_propertydeprecated_functiondeprecated_methodc                   ,    e Zd ZdZd Zd Zed        Zy)r
   zjFunction decorator which acts like a combination of classmethod+property (limited to read-only properties)c                     || _         y Nim_funcselffuncs     U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/utils/decor.py__init__zclassproperty.__init__#   s	        c                 $    | j                  |      S r   r   r   objclss      r   __get__zclassproperty.__get__&   s    ||C  r   c                     | j                   S )zpy3 compatible aliasr   r   s    r   __func__zclassproperty.__func__)   s     ||r   N)__name__
__module____qualname____doc__r   r   propertyr"    r   r   r
   r
       s#    t!  r   r
   c                       e Zd ZdZd Zd Zy)r   z
    decorator which invokes function with class if called as class method,
    and with object if called at instance level.
    c                 *    || _         t        | |       y r   )r   r   r   s     r   r   zhybrid_method.__init__4   s    	tT"r   c                     ||}t         r t        j                  | j                  |      S t        j                  | j                  ||      S r   )r	   types
MethodTyper   r   s      r   r   zhybrid_method.__get__8   s?    ;C##DIIs33##DIIsC88r   N)r#   r$   r%   r&   r   r   r(   r   r   r   r   .   s    
#9r   r   c                 N     i t                fd       }fd}||_        |S )z
    decorator for function which takes no args,
    and memoizes result.  exposes a ``.clear_cache`` method
    to clear the cached value.
    c                  J    	 d   S # t         $ r Y nw xY w        x} d<   | S NT)KeyError)valuecacher   s    r   wrapperz%memoize_single_value.<locals>.wrapperL   s9    	; 		"f$ds    	c                  *     j                  dd        y r0   )pop)r3   s   r   clear_cachez)memoize_single_value.<locals>.clear_cacheU   s    		$r   )r   r7   )r   r4   r7   r3   s   `  @r   r   r   D   s2     E
4[ %GNr   c                   >    e Zd ZdZd Zd Zesed        Zd Z	ddZ
y)	r   zM
    decorator which invokes method once, then replaces attr with result
    c                 V    || _         |j                  | _        |j                  | _        y r   )r"   r#   r&   r   s     r   r   zmemoized_property.__init___   s    ||r   c                 ^    || S | j                  |      }t        || j                  |       |S r   )r"   setattrr#   )r   r   r   r2   s       r   r   zmemoized_property.__get__d   s/    ;Kc"T]]E*r   c                     | j                   S )z	py2 alias)r"   r!   s    r   r   zmemoized_property.im_funcm   s     == r   c                 P    |j                   j                  | j                  d       y)z
        class-level helper to clear stored value (if any).

        usage: :samp:`type(self).{attr}.clear_cache(self)`
        N)__dict__r6   r#   )r   r   s     r   r7   zmemoized_property.clear_cacher   s     	-r   Nc                 N    |j                   j                  | j                  |      S )z
        class-level helper to peek at stored value

        usage: :samp:`value = type(self).{attr}.clear_cache(self)`
        )r>   getr#   )r   r   defaults      r   
peek_cachezmemoized_property.peek_cachez   s     ||w77r   r   )r#   r$   r%   r&   r   r   r	   r'   r   r7   rB   r(   r   r   r   r   [   s2    $
 		! 
	!.8r   r   c                 v      $rd nd r dz   r dz   r dz  z    dz    fd}|S )ab  decorator to deprecate a function.

    :arg msg: optional msg, default chosen if omitted
    :kwd deprecated: version when function was first deprecated
    :kwd removed: version when function will be removed
    :kwd replacement: alternate name / instructions for replacing this function.
    :kwd updoc: add notice to docstring (default ``True``)
    z5the method %(mod)s.%(klass)s.%(name)s() is deprecatedz-the function %(mod)s.%(name)s() is deprecatedz as of Passlib %(deprecated)sz,, and will be removed in Passlib %(removed)sz, use %s instead.c                 v    xr t         t              r  j                  d t              j                   t        xs  j                   j                  
      r	 	fd}n	z   fd}t        |        rs
r|j                  rd|j                  vrxs d}
sr%|dz  }
r|d
z  }r
r|dz  }|d	z  z  }|d
z  }|j                  j                  d      j                  d      s|xj                  dz  c_	        |xj                  d|dz  c_	        rt        |      }|S )N)modname
deprecatedremovedc                      j                         }r| d   n| d   j                  }|j                  |j                  |j                         t        |z  t        d        | i |S )Nr   )klassrF      
stacklevel)copy	__class__updater#   r$   r   DeprecationWarning)argskwdstmprK   r   is_classmethodmsgoptss       r   r4   z3deprecated_function.<locals>.build.<locals>.wrapper   s`    iik#1QtAw7H7H

U5E5E
FS3Y 2qAT*T**r   c                  8    t        t        d        | i |S )NrL   rM   )r   rR   )rS   rT   r   texts     r   r4   z3deprecated_function.<locals>.build.<locals>.wrapper   s     T-!<T*T**r   z.. deprecated:: z
    zand will be removed in version z, zuse %s insteadrD    
z
.. deprecated:: )
isinstanceclassmethodr   typer"   dictr$   r#   r   r&   stripendswith)r   r4   txtrV   rX   rZ   
_is_methodrH   func_modulerW   rI   replacementupdocs   `  @@@r   buildz"deprecated_function.<locals>.build   s3   #E
4(E<<d+44D.t!	 + + :D+ 	w%jG??'8'O"C+x'KKCt+k99Cs
??((-66t<4'OO3@@O!'*Gr   r(   )rW   rH   rI   rh   rg   re   rf   ri   s   ``````` r   r   r      sa     {ICAC22CAAC%33Cs
) )T Lr   c                 $    t        | ||||d      S )aZ  decorator to deprecate a method.

    :arg msg: optional msg, default chosen if omitted
    :kwd deprecated: version when method was first deprecated
    :kwd removed: version when method will be removed
    :kwd replacement: alternate name / instructions for replacing this method.
    :kwd updoc: add notice to docstring (default ``True``)
    T)re   )r   )rW   rH   rI   rh   rg   s        r   r   r      s     sJ*.0 0r   )NNNTNFN)NNNTN)r&   
__future__r   r   r   logging	getLoggerr#   log	functoolsr   r   r,   warningsr   passlib.utils.compatr	   __all__objectr
   r   r   r   r   r   r(   r   r   <module>rt      s    A @ g! +   %	F 9F 9,.%8 %8x HL5:$(AF FJ"&0r   