usr/lib64/python2.7/weakref.pyc000064400000040071147204444700012216 0ustar00 zfc @sdZddlZddlmZmZmZmZmZmZm Z m Z ddl m Z m Z ddlmZeefZdddd d d d d ddddg ZdejfdYZdefdYZd ejfdYZdS(s{Weak reference support for Python. This module is an implementation of PEP 205: http://www.python.org/dev/peps/pep-0205/ iN(tgetweakrefcountt getweakrefstreftproxytCallableProxyTypet ProxyTypet ReferenceTypet_remove_dead_weakref(tWeakSett_IterationGuard(tReferenceErrorRRRRtWeakKeyDictionaryR RRRt ProxyTypestWeakValueDictionaryRcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z e Z d Zdd Zd ZdZdZeZdZdZdZdZddZdZdZdZRS(sMapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore cOs|stdn|d}|d}t|dkrTtdt|nt|td}||_g|_t|_tjj |||dS(NsGdescriptor '__init__' of 'WeakValueDictionary' object needs an argumentiis$expected at most 1 arguments, got %dcSsN|}|dk rJ|jr4|jj|jqJ||j|jndS(N(tNonet _iteratingt_pending_removalstappendtkeytdata(twrtselfreft_atomic_removaltself((s/usr/lib64/python2.7/weakref.pytremove8s    ( t TypeErrortlenRRt_removeRtsetRtUserDictt__init__(targstkwRR((s/usr/lib64/python2.7/weakref.pyR0s     cCs<|j}|j}x#|r7|j}t||qWdS(N(RRtpopR(RtltdR((s/usr/lib64/python2.7/weakref.pyt_commit_removalsGs     cCsF|jr|jn|j|}|dkr>t|n|SdS(N(RR$RRtKeyError(RRto((s/usr/lib64/python2.7/weakref.pyt __getitem__Ps     cCs$|jr|jn|j|=dS(N(RR$R(RR((s/usr/lib64/python2.7/weakref.pyt __delitem__Ys  cCsI|jr|jny|j|}Wntk r>tSX|dk S(N(RR$RR%tFalseR(RRR&((s/usr/lib64/python2.7/weakref.pyt __contains__^s   cCsI|jr|jny|j|}Wntk r>tSX|dk S(N(RR$RR%R)R(RRR&((s/usr/lib64/python2.7/weakref.pythas_keygs   cCsdt|S(Ns(tid(R((s/usr/lib64/python2.7/weakref.pyt__repr__pscCs6|jr|jnt||j||j|s    ccsL|jr|jnt|$x|jjD] }|Vq3WWdQXdS(sReturn an iterator that yields the weak references to the values. The references are not guaranteed to be 'live' at the time they are used, so the result of calling the references needs to be checked before being used. This can be used to avoid creating references that will cause the garbage collector to keep the values around longer than needed. N(RR$R RR<(RR((s/usr/lib64/python2.7/weakref.pyt itervaluerefss   ccsd|jr|jnt|<x4|jjD]#}|}|dk r3|Vq3q3WWdQXdS(N(RR$R RR<R(RRtobj((s/usr/lib64/python2.7/weakref.pyR<s     cCsU|jr|jnx8|jj\}}|}|dk r||fSqWdS(N(RR$RtpopitemR(RRRR&((s/usr/lib64/python2.7/weakref.pyRBs    cGsw|jr|jny|jj|}Wntk rHd}nX|dkro|rc|dSt|n|SdS(Ni(RR$RR!R%R(RRRR&((s/usr/lib64/python2.7/weakref.pyR!s      cCsx|jr|jny|j|}Wntk rCd}nX|dkrpt||j||j|<|S|SdS(N(RR$RR%RR.R(RRR9R&((s/usr/lib64/python2.7/weakref.pyt setdefaults     cOs|stdn|d}|d}t|dkrTtdt|n|rd|dnd}|jr|jn|j}|dk rt|dsti|}nx6|jD]%\}}t ||j |||t__iter__R@R<RBR!RCRFRJRI(((s/usr/lib64/python2.7/weakref.pyR $s4            R.cBs&eZdZdZdZdZRS(s[Specialized reference that includes a key corresponding to the value. This is used in the WeakValueDictionary to avoid having to create a function object for each key stored in the mapping. A shared callback object can use the 'key' attribute of a KeyedRef instead of getting a reference to the key from an enclosing scope. RcCs"tj|||}||_|S(N(Rt__new__R(REtobtcallbackRR((s/usr/lib64/python2.7/weakref.pyRP6s cCstt|j||dS(N(tsuperR.R(RRQRRR((s/usr/lib64/python2.7/weakref.pyR;s(R(RKRLRMt __slots__RPR(((s/usr/lib64/python2.7/weakref.pyR.*s cBseZdZddZdZdZdZdZdZ dZ e Z dZ dd Z d Zd Zd Zd ZdZdZeZdZdZdZdZdZddZddZRS(s Mapping class that references keys weakly. Entries in the dictionary will be discarded when there is no longer a strong reference to the key. This can be used to associate additional data with an object owned by other parts of an application without adding attributes to those objects. This can be especially useful with objects that override attribute accesses. cCsYi|_t|d}||_g|_t|_|dk rU|j|ndS(NcSsB|}|dk r>|jr1|jj|q>|j|=ndS(N(RRRRR(R?RR((s/usr/lib64/python2.7/weakref.pyRLs    (RRRRRRRRF(RRHR((s/usr/lib64/python2.7/weakref.pyRJs     cCsH|j}|j}x/|rCy||j=Wqtk r?qXqWdS(N(RRR!R%(RR"R#((s/usr/lib64/python2.7/weakref.pyR$Zs    cCs|jt|=dS(N(RR(RR((s/usr/lib64/python2.7/weakref.pyR(gscCs|jt|S(N(RR(RR((s/usr/lib64/python2.7/weakref.pyR'jscCsdt|S(Ns(R,(R((s/usr/lib64/python2.7/weakref.pyR-mscCs||jt||j(RR((s/usr/lib64/python2.7/weakref.pyt iterkeyrefss ccsNt|<x4|jjD]#}|}|dk r|VqqWWdQXdS(N(R RR>R(RRRA((s/usr/lib64/python2.7/weakref.pyR>s    ccs6t|$x|jjD] }|VqWWdQXdS(N(R RR<(RR/((s/usr/lib64/python2.7/weakref.pyR<s cCs |jjS(szReturn a list of weak references to the keys. The references are not guaranteed to be 'live' at the time they are used, so the result of calling the references needs to be checked before being used. This can be used to avoid creating references that will cause the garbage collector to keep the keys around longer than needed. (Rtkeys(R((s/usr/lib64/python2.7/weakref.pytkeyrefss cCsIg}x<|jjD]+}|}|dk r|j|qqW|S(N(RRVRR(RR;RR&((s/usr/lib64/python2.7/weakref.pyRVs   cCs?x8|jj\}}|}|dk r||fSqWdS(N(RRBR(RRR/R&((s/usr/lib64/python2.7/weakref.pyRBs   cGs|jjt||S(N(RR!R(RRR((s/usr/lib64/python2.7/weakref.pyR!scCs|jjt||j|S(N(RRCRR(RRR9((s/usr/lib64/python2.7/weakref.pyRCscKs|j}|dk rot|ds9ti|}nx3|jD]"\}}||t||jROR<RWRVRBR!RCRF(((s/usr/lib64/python2.7/weakref.pyR ?s2                   (RMRt_weakrefRRRRRRRRt _weakrefsetRR t exceptionsR R t__all__R R.R (((s/usr/lib64/python2.7/weakref.pyts :