Current File : //usr/lib/python2.7/site-packages/passlib/utils/decor.pyc
�
	�Xc@`sdZddlmZmZmZddlZeje�Zddl	m
Z
mZddlZddl
mZddlmZddd	d
ddgZdefd
��YZdefd��YZd�Zd
efd��YZdddededd�Zdddedd�ZdS(s7
passlib.utils.decor -- helper decorators & properties
i(tabsolute_importtdivisiontprint_functionN(twrapstupdate_wrapper(twarn(tPY3t
classpropertyt
hybrid_methodtmemoize_single_valuetmemoized_propertytdeprecated_functiontdeprecated_methodcB`s/eZdZd�Zd�Zed��ZRS(sjFunction decorator which acts like a combination of classmethod+property (limited to read-only properties)cC`s
||_dS(N(tim_func(tselftfunc((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt__init__#scC`s
|j|�S(N(R
(Rtobjtcls((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt__get__&scC`s|jS(spy3 compatible alias(R
(R((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt__func__)s(t__name__t
__module__t__doc__RRtpropertyR(((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR s		cB`s eZdZd�Zd�ZRS(s�
    decorator which invokes function with class if called as class method,
    and with object if called at instance level.
    cC`s||_t||�dS(N(RR(RR((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR4s	cC`sH|dkr|}ntr.tj|j|�Stj|j||�SdS(N(tNoneRttypest
MethodTypeR(RRR((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR8s
	(RRRRR(((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR.s	c`s@i�t����fd��}�fd�}||_|S(s�
    decorator for function which takes no args,
    and memoizes result.  exposes a ``.clear_cache`` method
    to clear the cached value.
    c`s5y�tSWntk
rnX��}�t<|S(N(tTruetKeyError(tvalue(tcacheR(s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pytwrapperLs
c`s�jtd�dS(N(tpopRR((R(s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pytclear_cacheUs(RR"(RR R"((RRs7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR	Ds
		cB`sMeZdZd�Zd�Zes6ed��Znd�Zdd�Z
RS(sM
    decorator which invokes method once, then replaces attr with result
    cC`s%||_|j|_|j|_dS(N(RRR(RR((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR_s	cC`s6|dkr|S|j|�}t||j|�|S(N(RRtsetattrR(RRRR((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyRds
cC`s|jS(s	py2 alias(R(R((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR
mscC`s|jj|jd�dS(s�
        class-level helper to clear stored value (if any).

        usage: :samp:`type(self).{attr}.clear_cache(self)`
        N(t__dict__R!RR(RR((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR"rscC`s|jj|j|�S(s�
        class-level helper to peek at stored value

        usage: :samp:`value = type(self).{attr}.clear_cache(self)`
        (R$tgetR(RRtdefault((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt
peek_cachezsN(RRRRRRRR
R"RR'(((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR
[s			c`s��dkrk�rd�nd��r4�d7�n�rG�d7�n�r^�d�7�n�d7�n�������fd�}|S(	sbdecorator 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``)
    s5the method %(mod)s.%(klass)s.%(name)s() is deprecateds-the function %(mod)s.%(name)s() is deprecateds as of Passlib %(deprecated)ss,, and will be removed in Passlib %(removed)ss, use %s insteadt.c`s��ot�t���r3�jdt�j�ntd�pE�jd�jd�d����r�����fd�}n�����fd�}t	|���
r��s��r�|j
r�d|j
kr��p�d}�s��	rG|d	7}�r|d
�f7}n�	r:�r)|d7}n|d�	7}n|d
7}n|j
jd�jd�st|j
d7_
n|j
d|f7_
n�r�t|�}n|S(Ntmodtnamet
deprecatedtremovedc`si�j�}�r|dn
|dj}|jd|jd|j�t�|tdd��||�S(NitklassR)t
stackleveli(tcopyt	__class__tupdateRRRtDeprecationWarning(targstkwdsttmpR-(Rtis_classmethodtmsgtopts(s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR �s
c`s t�tdd��||�S(NR.i(RR2(R3R4(Rttext(s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR �ss.. deprecated::ts
    s!and will be removed in version %ss, suse %s insteadR(t s
s
.. deprecated:: %s
(
t
isinstancetclassmethodRRttypeRtdictRRRRtstriptendswith(RR ttxt(t
_is_methodR+tfunc_moduleR7R,treplacementtupdoc(RR6R8R9s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pytbuild�s>		




N(R(R7R+R,RFRERCRDRG((RCR+RDR7R,RERFs7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR�s	


!*cC`st|||||dt�S(sZdecorator 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``)
    RC(RR(R7R+R,RFRE((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR�s
(Rt
__future__RRRtloggingt	getLoggerRtlogt	functoolsRRRtwarningsRtpasslib.utils.compatRt__all__tobjectRRR	R
RRtFalseRR(((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt<module>s,		<A