ó ’,bc @sîdZddlZddlmZmZmZmZmZmZm Z ddl m Z m Z ddl mZeefZdddd d d d d ddddg Zdejfd„ƒYZdefd„ƒYZd ejfd„ƒYZdS(s{Weak reference support for Python. This module is an implementation of PEP 205: http://www.python.org/dev/peps/pep-0205/ iÿÿÿÿN(tgetweakrefcountt getweakrefstreftproxytCallableProxyTypet ProxyTypet ReferenceType(tWeakSett_IterationGuard(tReferenceErrorRRRRtWeakKeyDictionaryR RRRt ProxyTypestWeakValueDictionaryRcBsïeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z e Z d „Zdd „Zd „Zd„Zd„ZeZd„Zd„Zd„Zd„Zdd„Zd„Zd„Zd„ZRS(s›Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore cOsž|stdƒ‚n|d}|d}t|ƒdkrTtdt|ƒƒ‚nt|ƒd„}||_g|_tƒ|_tjj|||ŽdS(NsGdescriptor '__init__' of 'WeakValueDictionary' object needs an argumentiis$expected at most 1 arguments, got %dcSsH|ƒ}|dk rD|jr4|jj|jƒqD|j|j=ndS(N(tNonet _iteratingt_pending_removalstappendtkeytdata(twrtselfreftself((s/usr/lib/python2.7/weakref.pytremove7s    ( t TypeErrortlenRt_removeRtsetRtUserDictt__init__(targstkwRR((s/usr/lib/python2.7/weakref.pyR/s     cCs0|j}|j}x|r+||jƒ=qWdS(N(RRtpop(Rtltd((s/usr/lib/python2.7/weakref.pyt_commit_removalsDs   cCs0|j|ƒ}|dkr(t|‚n|SdS(N(RR tKeyError(RRto((s/usr/lib/python2.7/weakref.pyt __getitem__Ls  cCs$|jr|jƒn|j|=dS(N(RR"R(RR((s/usr/lib/python2.7/weakref.pyt __delitem__Ss  cCs3y|j|ƒ}Wntk r(tSX|dk S(N(RR#tFalseR (RRR$((s/usr/lib/python2.7/weakref.pyt __contains__Xs  cCs3y|j|ƒ}Wntk r(tSX|dk S(N(RR#R'R (RRR$((s/usr/lib/python2.7/weakref.pythas_key_s  cCsdt|ƒS(Ns(tid(R((s/usr/lib/python2.7/weakref.pyt__repr__fscCs6|jr|jƒnt||j|ƒ|j|R:R@RRARDRHRG(((s/usr/lib/python2.7/weakref.pyR #s4                  R,cBs&eZdZdZd„Zd„ZRS(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(RCtobtcallbackRR((s/usr/lib/python2.7/weakref.pyRNs cCstt|ƒj||ƒdS(N(tsuperR,R(RRORPR((s/usr/lib/python2.7/weakref.pyRs(R(RIRJRKt __slots__RNR(((s/usr/lib/python2.7/weakref.pyR, s cBsìeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z e Z d„Z dd „Z d „Zd „Zd „Zd „Zd„Zd„ZeZd„Zd„Zd„Zd„Zd„Zdd„Zdd„ZRS(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(R RRRR(R=RR((s/usr/lib/python2.7/weakref.pyR+s    (RRRRRRR RD(RRFR((s/usr/lib/python2.7/weakref.pyR)s     cCsH|j}|j}x/|rCy||jƒ=Wqtk r?qXqWdS(N(RRRR#(RR R!((s/usr/lib/python2.7/weakref.pyR"9s    cCs|jt|ƒ=dS(N(RR(RR((s/usr/lib/python2.7/weakref.pyR&FscCs|jt|ƒS(N(RR(RR((s/usr/lib/python2.7/weakref.pyR%IscCsdt|ƒS(Ns(R*(R((s/usr/lib/python2.7/weakref.pyR+LscCs||jt||jƒs 4    æ