Xc@`sdZddlmZmZmZddlZejeZddl m Z m Z ddl Z ddl mZddlmZddd d d d gZdefd YZdefdYZdZd efdYZdddededdZdddeddZdS(s7 passlib.utils.decor -- helper decorators & properties i(tabsolute_importtdivisiontprint_functionN(twrapstupdate_wrapper(twarn(tPY3t classpropertyt hybrid_methodtmemoize_single_valuetmemoized_propertytdeprecated_functiontdeprecated_methodcB`s/eZdZdZdZedZRS(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 eZdZdZdZRS(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@itfd}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`sjtddS(N(tpopRR((R(s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyt clear_cacheUs(RR"(RR R"((RRs7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR Ds   cB`sMeZdZdZdZes6edZndZddZ 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|jddS(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`sdkrkrdndr4d7nrGd7nr^d7nd7nfd}|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 `sottr3jdtjntdpEjdjddrfd}nfd}t | rsr|j rd|j krpd}s rG|d 7}r|d f7}n r:r)|d 7}n|d 7}n|d 7}n|j j dj dst|j d7_ n|j d|f7_ nrt|}n|S(Ntmodtnamet deprecatedtremovedc`sij}r|dn |dj}|jd|jd|jt|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 ttdd||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 isinstancet classmethodRRttypeRtdictRRRRtstriptendswith(RR ttxt(t _is_methodR+t func_moduleR7R,t replacementtupdoc(RR6R8R9s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pytbuilds>         N(R(R7R+R,RFRERCRDRG((RCR+RDR7R,RERFs7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyR s     !*cC`st|||||dtS(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(R R(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 RRtFalseR R (((s7/usr/lib/python2.7/site-packages/passlib/utils/decor.pyts,    <  A