Pc@sVdZdZdddgZddlZddlZddlZejdkrjddlmZd Znd e fd YZd Zej d Z de fdYZ ddZdZy2ddlmZedefedeZWnNek rEddlmZdZedefededeZnXeeZdS(sT Decorator module, see http://pypi.python.org/pypi/decorator for the documentation. s3.4.0t decoratort FunctionMakertcontextmanageriNt3(tgetfullargspeccCs|jS(N(t__init__(tcls((s-/usr/lib/python2.7/site-packages/decorator.pytget_init*sRcBs eZdZdZdZRS(s?A quick and dirty replacement for getfullargspec for Python 2.XcCs=tj|\|_|_|_|_g|_d|_dS(N( tinspectt getargspectargstvarargstvarkwtdefaultst kwonlyargstNonetkwonlydefaults(tselftf((s-/usr/lib/python2.7/site-packages/decorator.pyR/s' ccs$|jV|jV|jV|jVdS(N(R R R R (R((s-/usr/lib/python2.7/site-packages/decorator.pyt__iter__4s(t__name__t __module__t__doc__RR(((s-/usr/lib/python2.7/site-packages/decorator.pyR-s cCs |jjS(N(Rtim_func(R((s-/usr/lib/python2.7/site-packages/decorator.pyR9ss\s*def\s*([_\w][_\w\d]*)\s*\(cBs_eZdZddddddddZdZdedZeddde dZ RS(s An object with the ability to create functions with a given signature. It has attributes name, doc, module, signature, defaults, dict and methods update and make. cCs||_|r.|j|_|jdkr6d|_n|j|_|j|_tj|r.t |}t |di|_ x'dD]} t || t || qWx1t |jD] \} } t |d | | qWtjd krtjd d |dd!|_|_nt|j} t|j} |jri| jd|j| jd|jn|jr| jdnx9|jD].} | jd| | jd| | fqW|jr| jd|j| jd|jndj| |_dj| |_|jj|_q.n|r@||_n|dk rX||_n|rj||_n|r|||_n|r||_n|r||_nt|dstt|dst d|ndS(Nst_lambda_t__annotations__R R R R RRsarg%dRt formatvaluecSsdS(Nt((tval((s-/usr/lib/python2.7/site-packages/decorator.pytZsiit*s%s=Nones%s=%ss**s, tnamet signatures%You are decorating a non function: %s(sargssvarargssvarkwsdefaultss kwonlyargsskwonlydefaults(!tshortsignatureRRRtdocRtmoduleRt isfunctionRtgetattrt annotationstsetattrt enumerateR tsystversiont formatargspecR tlistR tappendRR tjoint__dict__tcopytdictRR thasattrtAssertionErrort TypeError(RtfuncRR R R"R#tfuncdicttargspectatitargtallargst allshortargs((s-/usr/lib/python2.7/site-packages/decorator.pyREsb        #          cKs|j|_t|dd |_t|di|_t|dd |_t|dd |_t|dd |_t j dj j dd}t|d ||_ |jj|d S( s2Update the signature of func with the data in selfR"R1R RR&iRt?R#N((RRR%RRR/t func_defaultst__kwdefaults__RR)t _getframet f_globalstgetRtupdate(RR5tkwt callermodule((s-/usr/lib/python2.7/site-packages/decorator.pyRC~s c Js\|e|}|pi}ej|}|d krJed|n|jd}e|gg|jjdD]}|j d^qu} x3| D]+} | dkre d| |fqqW|j ds|d7}nye |d d } | |UWn$e jd IJe j|IJnX||} |rH||d tsinglesError in generated code:t __source__N(s_func_RH(tvarstDEFtmatchRt SyntaxErrortgrouptsetR!tsplittstript NameErrortendswithtcompileR)tstderrRC( Rt src_templtevaldictt addsourcetattrstsrctmoRR:tnamestntcodeR5((s-/usr/lib/python2.7/site-packages/decorator.pytmakes2   /        cKst|tr@|jjdd\} } | d } d} nd} d} |} || | | |||} djd|jD}| jd||||S(s Create a function from the strings name, signature and body. evaldict is the evaluation dictionary. If addsource is true an attribute __source__ is added to the result. The attributes attrs are added, if any. t(iis css|]}d|VqdS(s N((t.0tline((s-/usr/lib/python2.7/site-packages/decorator.pys ssdef %(name)s(%(signature)s): N(t isinstancetstrRRRQRR.t splitlinesR`(RtobjtbodyRXR R"R#RYRZRtrestR R5Rtibody((s-/usr/lib/python2.7/site-packages/decorator.pytcreates    N( RRRRRRCtFalseR`t classmethodtTrueRk(((s-/usr/lib/python2.7/site-packages/decorator.pyR?s 8 c Cs|dk rN|jj}||d<||dRiRs%s(%s)sreturn decorator(_call_, %s)R"R#N(Rt func_globalsR0RRkRtisclassRtlowerRRR R$Rt __class__t__call__RRR(tcallerR5RXRt callerfuncR"tfun((s-/usr/lib/python2.7/site-packages/decorator.pyRs>           cCs(tj|dtd|d|d|S(sContext manager decorators.with _self_: return _func_(%(shortsignature)s)t_self_RGRp(RRkR1(RR5((s-/usr/lib/python2.7/site-packages/decorator.pyRus(t_GeneratorContextManagertContextManagerRu(tGeneratorContextManagercOstj||||S(N(R|R(RRR8tk((s-/usr/lib/python2.7/site-packages/decorator.pyRsR(Rt __version__t__all__R)treRR*RRtobjectRURLRRRRut contextlibRzttypeR1R{t ImportErrorR|RR(((s-/usr/lib/python2.7/site-packages/decorator.pyt!s.$  ~ )