
    g                         S r SSKJrJrJr  SSKr\R                  " \5      rSSK	J
r
Jr  SSKrSSKJr  SSKJr  / SQr " S S	\5      r " S
 S\5      rS r " S S\5      r   SS jr  SS jrg)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                   4    \ rS rSrSrS rS r\S 5       rSr	g)r
       zjFunction decorator which acts like a combination of classmethod+property (limited to read-only properties)c                     Xl         g Nim_funcselffuncs     L/home/matz/Project1/venv/lib/python3.13/site-packages/passlib/utils/decor.py__init__classproperty.__init__#   s        c                 $    U R                  U5      $ r   r   r   objclss      r   __get__classproperty.__get__&   s    ||C  r   c                     U R                   $ )zpy3 compatible aliasr   r   s    r   __func__classproperty.__func__)   s     ||r   r   N)
__name__
__module____qualname____firstlineno____doc__r   r!   propertyr%   __static_attributes__ r   r   r
   r
       s#    t!  r   r
   c                   $    \ rS rSrSrS rS rSrg)r   .   zu
decorator which invokes function with class if called as class method,
and with object if called at instance level.
c                 &    Xl         [        X5        g r   )r   r   r   s     r   r   hybrid_method.__init__4   s    	t"r   c                     Uc  Un[         (       a!  [        R                  " U R                  U5      $ [        R                  " U R                  X5      $ r   )r	   types
MethodTyper   r   s      r   r!   hybrid_method.__get__8   s?    ;C3##DIIs33##DIIs88r   )r   N)r'   r(   r)   r*   r+   r   r!   r-   r.   r   r   r   r   .   s    
#9r   r   c                 P   ^ ^ 0 m[        T 5      UU 4S j5       nU4S jnX!l        U$ )z
decorator for function which takes no args,
and memoizes result.  exposes a ``.clear_cache`` method
to clear the cached value.
c                  L   >  TS   $ ! [          a     Of = fT" 5       =n TS'   U $ NT)KeyError)valuecacher   s    r   wrapper%memoize_single_value.<locals>.wrapperL   s9    	; 		"f$ds    
c                  *   > T R                  SS 5        g r9   )pop)r<   s   r   clear_cache)memoize_single_value.<locals>.clear_cacheU   s    		$r   )r   rA   )r   r=   rA   r<   s   `  @r   r   r   D   s0     E
4[ %Nr   c                   R    \ rS rSrSrS rS r\(       d  \S 5       r	S r
S
S jrS	rg)r   [   zE
decorator which invokes method once, then replaces attr with result
c                 T    Xl         UR                  U l        UR                  U l        g r   )r%   r'   r+   r   s     r   r   memoized_property.__init___   s    ||r   c                 ^    Uc  U $ U R                  U5      n[        XR                  U5        U$ r   )r%   setattrr'   )r   r   r    r;   s       r   r!   memoized_property.__get__d   s-    ;Kc"]]E*r   c                     U R                   $ )z	py2 alias)r%   r$   s    r   r   memoized_property.im_funcm   s     == r   c                 P    UR                   R                  U R                  S5        g)zh
class-level helper to clear stored value (if any).

usage: :samp:`type(self).{attr}.clear_cache(self)`
N)__dict__r@   r'   )r   r   s     r   rA   memoized_property.clear_cacher   s     	-r   Nc                 N    UR                   R                  U R                  U5      $ )zh
class-level helper to peek at stored value

usage: :samp:`value = type(self).{attr}.clear_cache(self)`
)rM   getr'   )r   r   defaults      r   
peek_cachememoized_property.peek_cachez   s     ||w77r   )r+   r%   r'   r   )r'   r(   r)   r*   r+   r   r!   r	   r,   r   rA   rR   r-   r.   r   r   r   r   [   s2    $
 		! 
	!.8r   r   c                    ^ ^^^^^^ T c8  T(       a  Sm OSm T(       a  T S-  m T(       a  T S-  m T(       a  T ST-  -  m T S-  m UUUU UUU4S jnU$ )aJ  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                   >^ ^^^ T=(       a    [        T [        5      mT(       a   T R                  S [        5      R                  m [        T=(       d    T R                  T R                  TT
S9mT(       a
  U UU	U4S jnOT	T-  mU U4S jn[        UT 5        T(       a  T(       d  T
(       a  UR                  (       a  SUR                  ;  a  T=(       d    SnT
(       d  T(       a5  US-  nT
(       a	  UST
< 3-  nT(       a  T
(       a  US-  nUS	T-  -  nUS
-  nUR                  R                  S5      R                  S5      (       d  U=R                  S-  sl	        U=R                  SU< S3-  sl	        T(       a  [        U5      nU$ )N)modname
deprecatedremovedc                     > TR                  5       nT(       a  U S   OU S   R                  nUR                  UR                  UR                  S9  [        TU-  [        SS9  T" U 0 UD6$ )Nr   )klassrW      
stacklevel)copy	__class__updater'   r(   r   DeprecationWarning)argskwdstmpr\   r   is_classmethodmsgoptss       r   r=   3deprecated_function.<locals>.build.<locals>.wrapper   s`    iik#1QtAw7H7H

U5E5E
FS3Y 2qAT*T**r   c                  2   > [        T[        SS9  T" U 0 UD6$ )Nr]   r^   )r   rc   )rd   re   r   texts     r   r=   rj      s     T-!<T*T**r   z.. deprecated:: z
    zand will be removed in version z, zuse %s insteadrU    
z
.. deprecated:: )
isinstanceclassmethodr!   typer%   dictr(   r'   r   r+   stripendswith)r   r=   txtrg   ri   rl   
_is_methodrY   func_modulerh   rZ   replacementupdocs   `  @@@r   build"deprecated_function.<locals>.build   s6   #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.   )rh   rY   rZ   rz   ry   rw   rx   r{   s   ``````` r   r   r      sa     {ICAC22CAAC%33Cs
) )T Lr   c           	          [        XX#USS9$ )aB  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)rw   )r   )rh   rY   rZ   rz   ry   s        r   r   r      s     s*.0 0r   )NNNTNFN)NNNTN)r+   
__future__r   r   r   logging	getLoggerr'   log	functoolsr   r   r4   warningsr   passlib.utils.compatr	   __all__objectr
   r   r   r   r   r   r.   r   r   <module>r      s    A @ ! +   %	F 9F 9,.%8 %8x HL5:$(AF FJ"&0r   