Ñò Get an enclosing frame that skips DecoratorTools callback codet__name__(tsyst _getframet f_globalstgetRtf_back(Rtlevel((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR $s cCskddkl}l}|i}|djo d}n||ƒ\}}}}|||||ƒdd!fS(Niÿÿÿÿ(t formatargspect getargspecst anonymousi(tinspectR R!R(tfuncR R!tfuncnametargstvarargstkwargstdefaults((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyt name_and_spec*s    cCs)|i}|o|d|ip|iS(Nt.(t __module__R(R$tm((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pytqname3s c Nsòe|ƒ\}}e|ƒ\}}|iiddƒiddƒ}h} d|d}|eƒ;}de|ƒe|ƒe|ƒf} e|| dƒ|i| U| ||||Ž} e| || ƒ|i | _ |i| _|i | _ | S( Nt%s%%s$argss %(argspec)ssA def %(wrapname)s(%(wrapspec)s): def %(funcname)s(%(argspec)s): s return %(funcname)s s<%s wrapping %s at 0x%08X>texec( R*t__doc__treplacetlocalsR.tidtcompilet func_globalsR t func_defaultst__dict__( twrapperR$R&tkwR%targspectwrapnametwrapspectbodyRtfilenametf((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pytapply_template8s! %   cCsd„}t|||ƒS(sCreate a wrapper with the signature of `func` and a body of `wrapper` Example:: def before_and_after(func): def decorated(*args, **kw): print "before" try: return func(*args, **kw) finally: print "after" return rewrap(func, decorated) The above function is a normal decorator, but when users run ``help()`` or other documentation tools on the returned wrapper function, they will see a function with the original function's name, signature, module name, etc. This function is similar in use to the ``@template_function`` decorator, but rather than generating the entire decorator function in one calling layer, it simply generates an extra layer for signature compatibility. NOTE: the function returned from ``rewrap()`` will have the same attribute ``__dict__`` as the original function, so if you need to set any function attributes you should do so on the function returned from ``rewrap()`` (or on the original function), and *not* on the wrapper you're passing in to ``rewrap()``. cSsdS(sreturn __decorated($args)N((t __originalt __decorated((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR ps(RA(R$R9R ((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR Ss s2.5cCsê|djotiiƒ}n"|tijo |g}ndSx¢|D]š}ti|\}}}}|djoqHnyti|ƒ}Wn#tij oti|=qHnX||ijp||ijoti|=qHqHWdS(sYDiscard cache entries that are out of date. (This is not checked upon each call!)N( tNonet linecachetcachetkeystoststatterrortst_sizetst_mtime(R?t filenamestsizetmtimetlinestfullnameRI((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyt checkcache~s"     cs˜|djo ˆ}n)ddkl}||‡fd†ƒ}ddkatidjo tiitjo tt_ndd||fti ˆšss2.5i( RDtweakrefRSRERtversionRRR,RRF(R?RPtownerRS((R?s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyt _cache_lines•s   # cCst||itƒ|ƒdS(N(RZt splitlinestTrue(R?tsourceRY((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR  scCs(|djotd„ƒSti|ƒS(sËDecorator that uses its wrapped function's docstring as a template Example:: def before_and_after(func): @template_function def wrap(__func, __message): ''' print "before", __message try: return __func($args) finally: print "after", __message ''' return wrap(func, "test") The above code will return individually-generated wrapper functions whose signature, defaults, ``__name__``, ``__module__``, and ``func_globals`` match those of the wrapped functions. You can use define any arguments you wish in the wrapping function, as long as the first argument is the function to be wrapped, and the arguments are named so as not to conflict with the arguments of the function being wrapped. (i.e., they should have relatively unique names.) Note that the function body will *not* have access to the globals of the calling module, as it is compiled with the globals of the *wrapped* function! Thus, any non-builtin values that you need in the wrapper should be passed in as arguments to the template function. cSs t|ƒS((R (R@RRto((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyRVÅsN(RDRRAt__get__(R9((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR ¥s cs‡‡fd†}t|ƒS(s‰Turn a function into a simple data structure class This decorator creates a tuple subclass with the same name and docstring as the decorated function. The class will have read-only properties with the same names as the function's arguments, and the ``repr()`` of its instances will look like a call to the original function. The function should return a tuple of values in the same order as its argument names, as it will be used by the class' constructor. The function can perform validation, add defaults, and/or do type conversions on the values. If the function takes a ``*``, argument, it should flatten this argument into the result tuple, e.g.:: @struct() def pair(first, *rest): return (first,) + rest The ``rest`` property of the resulting class will thus return a tuple for the ``*rest`` arguments, and the structure's ``repr()`` will reflect the way it was created. The ``struct()`` decorator takes optional mixin classes (as positional arguments), and dictionary entries (as keyword arguments). The mixin classes will be placed before ``tuple`` in the resulting class' bases, and the dictionary entries will be placed in the class' dictionary. These entries take precedence over any default entries (e.g. methods, properties, docstring, etc.) that are created by the ``struct()`` decorator. cs‡fd†}‡fd†}ddk}|iˆƒ\}}} } td|d|dˆidˆid|d |d gƒ} xHt|ƒD]:\} } t| tƒot| d d „ƒ| | Metaclass that delegates selected operations back to the classcCsLtt|ƒi||||ƒ}t|dƒi}|ƒ|||||ƒS(Nt __class_new__(tsuperRµRbR´tnext(R‡RgR…R†Rctsupr((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyRbps!cCs+t|dƒi}|ƒ|||||ƒS(Nt__class_init__(R´R¸(RcRgR…R†R¹((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyt__init__uscOs|ii|||ŽS(N(t__class_call__R²(RcR&R:((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyt__call__ys(RR,R1RbR»R½(((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyRµms  cBsAeZdZeZdZd„Zd„Zd„Ze eƒZRS(s:Base class for classes that want to be their own metaclasscCsti||||ƒS(N(R`Rb(R‡RgR…R†R¹((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR¶‚scCsti||||ƒS(N(R`R»(RcRgR…R†R¹((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyRº…scOsti|||ŽS(N(R`R½(RcR&R:((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR¼ˆs(( RR,R1RµR„RjR¶RºR¼t classmethod(((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyR }s   (!ttypesRRRRHt__all__RRDR R*R.RAR RXRRRZR R RRRtFalseRRR–RŽRRR´R`RµtobjectR (((s8/usr/lib/python2.6/site-packages/peak/util/decorators.pyts8       )  ) R ) )M " )R