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|dstd|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, t signatures%You are decorating a non function: %s(sargssvarargssvarkwsdefaultss kwonlyargsskwonlydefaults( tshortsignatureRtnameRtdocRtmoduleRt isfunctionRtgetattrt annotationstsetattrt enumerateR tsystversiont formatargspecRtlistR tappendRR tjoint__dict__tcopytdictRR thasattrt TypeError(RtfuncR!RR R"R#tfuncdicttargspectatitargtallargst allshortargs((s-/usr/lib/python2.7/site-packages/decorator.pyREs`        #          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((R!RR%RRR/t func_defaultst__kwdefaults__RR)t _getframet f_globalstgetRtupdate(RR4tkwt callermodule((s-/usr/lib/python2.7/site-packages/decorator.pyRB~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_RG(tvarstDEFtmatchRt SyntaxErrortgrouptsetR tsplittstript NameErrortendswithtcompileR)tstderrRB( Rt src_templtevaldictt addsourcetattrstsrctmoR!R9tnamestntcodeR4((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 isinstancetstrRQRPRR.t splitlinesR_(RtobjtbodyRWR R"R#RXRYR!trestRR4Rtibody((s-/usr/lib/python2.7/site-packages/decorator.pytcreates    N( RRRRRRBtFalseR_t classmethodtTrueRj(((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_globalsR0RRjRtisclassRtlowerRRR R$Rt __class__t__call__RRR(tcallerR4RWR!t 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_RFRo(RRjR1(RR4((s-/usr/lib/python2.7/site-packages/decorator.pyRts(t_GeneratorContextManagertContextManagerRt(tGeneratorContextManagercOstj||||S(N(R{R(RRR7tk((s-/usr/lib/python2.7/site-packages/decorator.pyRsR(Rt __version__t__all__R)treRR*RRtobjectRTRKRRRRtt contextlibRyttypeR1Rzt ImportErrorR{RR(((s-/usr/lib/python2.7/site-packages/decorator.pyt!s.$  ~ )