-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/decorators.pyc

ó
¹àíNc@@sËddlmZddddgZddlZddlmZd„Zd	„Zd
„Zd„Z	d„Z
d
„Zeae	a
d„Zd„Zd„Zdefd„ƒYZdefd„ƒYZdS(i(tabsolute_importtneeds_read_locktneeds_write_locktuse_fast_decoratorstuse_pretty_decoratorsN(ttracec
@s'ddl}|j|ƒ\}}}}i‰‡fd†}|j|d|d|d|d|ƒ}|dkrx|}nLt|ƒt|ƒ}	||	 }x)||	D]}
|jd|
|
fƒq£W|dk	rä|jd	|ƒn|dk	r|jd
|ƒndj|ƒ}|dd
!|ˆfS(sFRecreate the parameters for a function using introspection.

    :return: (function_params, calling_params, default_values)
        function_params: is a string representing the parameters of the
            function. (such as "a, b, c=None, d=1")
            This is used in the function declaration.
        calling_params: is another string representing how you would call the
            function with the correct parameters. (such as "a, b, c=c, d=d")
            Assuming you used function_params in the function declaration, this
            is the parameters to put in the function call.
        default_values_block: a dict with the default values to be passed as
            the scope for the 'exec' statement.

        For example:

        def wrapper(%(function_params)s):
            return original(%(calling_params)s)
    iNc@s"dtˆƒ}|ˆ|<d|S(Ns__default_%dt=(tlen(tvaluetdefault_name(t
defaults_dict(s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pytformatvalue8s
tvarargstvarkwtdefaultsRs%s=%st*s**s, iiÿÿÿÿ(tinspectt
getargspect
formatargspectNoneRtappendtjoin(tfuncRtargsRR
RRt	formattedtargs_passedt
first_defaulttarg((R
s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt_get_parameterss(		
c	B@s‡d}e|ƒ\}}}i|jd6|d6|d6}||}e|ƒ}||d<||U|d}|j|_|j|_|S(sDecorate unbound to take out and release a read lock.

    This decorator can be applied to methods of any class with lock_read() and
    unlock() methods.

    Typical usage:

    class Branch(...):
        @needs_read_lock
        def branch_method(self, ...):
            stuff
    sÁdef %(name)s_read_locked(%(params)s):
    self.lock_read()
    try:
        result = unbound(%(passed_params)s)
    except:
        import sys
        exc_info = sys.exc_info()
        try:
            self.unlock()
        finally:
            try:
                raise exc_info[0], exc_info[1], exc_info[2]
            finally:
                del exc_info
    else:
        self.unlock()
        return result
read_locked = %(name)s_read_locked
tnametparamst
passed_paramstunboundtread_locked(Rt__name__tdictt__doc__(	R ttemplateRRR
t	variablestfunc_deftscopeR!((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt_pretty_needs_read_lockPs)




c@s+‡fd†}ˆj|_ˆj|_|S(sDecorate unbound to take out and release a read lock.

    This decorator can be applied to methods of any class with lock_read() and
    unlock() methods.

    Typical usage:

    class Branch(...):
        @needs_read_lock
        def branch_method(self, ...):
            stuff
    c@s‰|jƒyˆ|||Ž}WnTddl}|jƒ}z|jƒWdz|d|d|d‚Wd~XXnX|jƒ|SdS(Niii(t	lock_readtsystexc_infotunlock(tselfRtkwargstresultR+R,(R (s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyR!˜s
	
(R$R"(R R!((R s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt_fast_needs_read_lock‹s
c	B@s‡d}e|ƒ\}}}i|jd6|d6|d6}||}e|ƒ}||d<||U|d}|j|_|j|_|S(s6Decorate unbound to take out and release a write lock.sÅdef %(name)s_write_locked(%(params)s):
    self.lock_write()
    try:
        result = unbound(%(passed_params)s)
    except:
        import sys
        exc_info = sys.exc_info()
        try:
            self.unlock()
        finally:
            try:
                raise exc_info[0], exc_info[1], exc_info[2]
            finally:
                del exc_info
    else:
        self.unlock()
        return result
write_locked = %(name)s_write_locked
RRRR twrite_locked(RR"R#R$(	R R%RRR
R&R'R(R2((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt_pretty_needs_write_lock®s




c@s+‡fd†}ˆj|_ˆj|_|S(s6Decorate unbound to take out and release a write lock.c@s}|jƒyˆ|||Ž}WnHtjƒ}z|jƒWdz|d|d|d‚Wd~XXnX|jƒ|SdS(Niii(t
lock_writeR+R,R-(R.RR/R0R,(R (s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyR2×s
	
(R$R"(R R2((R s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt_fast_needs_write_lockÕsc@s‡fd†}|S(s	Make a decorator that will only allow the given error classes to be
    raised.  All other errors will be logged and then discarded.

    Typical use is something like::

        @only_raises(LockNotHeld, LockBroken)
        def unlock(self):
            # etc
    c@s.‡‡fd†}ˆj|_ˆj|_|S(Nc@sIyˆ||ŽSWn1ˆk
r'‚ntjdƒtjƒnXdS(Ns Error suppressed by only_raises:(Rtmuttertlog_exception_quietly(RR/(terrorsR (s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pytwrapped÷s

(R$R"(R R9(R8(R s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt	decoratorös((R8R:((R8s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pytonly_raisesìs
cC@statadS(sÆChange the default decorators to be fast loading ones.

    The alternative is to have decorators that do more work to produce
    nice-looking decorated functions, but this slows startup time.
    N(R1RR5R(((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyRscC@statadS(s0Change the default decorators to be pretty ones.N(R)RR3R(((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyRscC@sCt|tƒr|}t|ƒS|}d|j}t||ƒSdS(s2A decorator for methods that makes them properties with their return
    value cached.

    The value is cached on the instance, using the attribute name provided.

    If you don't provide a name, the mangled name of the property is used.

    >>> class CachedPropertyTest(object):
    ...
    ...     @cachedproperty('_foo_cache')
    ...     def foo(self):
    ...         print 'foo computed'
    ...         return 23
    ...
    ...     @cachedproperty
    ...     def bar(self):
    ...         print 'bar computed'
    ...         return 69

    >>> cpt = CachedPropertyTest()
    >>> getattr(cpt, '_foo_cache', None) is None
    True
    >>> cpt.foo
    foo computed
    23
    >>> cpt.foo
    23
    >>> cpt._foo_cache
    23
    >>> cpt.bar
    bar computed
    69
    >>> cpt._bar_cached_value
    69

    s_%s_cached_valueN(t
isinstancet
basestringt_CachedPropertyForAttrR"t_CachedProperty(tattrname_or_fntattrnametfn((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pytcachedproperty s%

R>cB@seZd„Zd„ZRS(cC@s
||_dS(N(RA(R.RA((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt__init__PscC@st|j|ƒS(N(R?RA(R.RB((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt__call__Ss(R"t
__module__RDRE(((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyR>Ns	R?cB@seZd„Zdd„ZRS(cC@s"||_||_tƒ|_dS(N(RBRAtobjecttmarker(R.RARB((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyRDYs		cC@se|dkr|St||j|jƒ}||jkr]|j|ƒ}t||j|ƒ|S|SdS(N(RtgetattrRARHRBtsetattr(R.tinsttclstcachedresultR0((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt__get__^sN(R"RFRDRRN(((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyR?Ws	(t
__future__Rt__all__R+tbzrlibRRR)R1R3R5R;RRRRRCRGR>R?(((s5/usr/lib/python2.7/dist-packages/bzrlib/decorators.pyt<module>s&		1	;	#	'				
	.	

Copyright © 2017 || Recoded By Mr.Bumblebee