³ò ¤l‡Jc @sÒdZddkZddklZlZlZlZlZlZl Z ddk l Z eefZ ddddd d d d d dg Z deifd„ƒYZdefd„ƒYZd eifd„ƒYZdS(sƒWeak reference support for Python. This module is an implementation of PEP 205: http://python.sourceforge.net/peps/pep-0205.html iÿÿÿÿN(tgetweakrefcountt getweakrefstreftproxytCallableProxyTypet ProxyTypet ReferenceType(tReferenceErrorRRRRtWeakKeyDictionaryRRRt ProxyTypestWeakValueDictionarycBsËeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z dd„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zdd„Zdd„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 cOs5t|ƒd„}||_tii|||ŽdS(NcSs+|ƒ}|dj o|i|i=ndS(N(tNonetdatatkey(twrtselfreftself((s/sys/lib/python/weakref.pytremove.s  (Rt_removetUserDictt__init__(RtargstkwR((s/sys/lib/python/weakref.pyR-s cCs2|i|ƒ}|djo t|‚n|SdS(N(R R tKeyError(RR to((s/sys/lib/python/weakref.pyt __getitem__5s  cCs8y|i|ƒ}Wntj o tSnX|dj S(N(R RtFalseR (RR R((s/sys/lib/python/weakref.pyt __contains__<s  cCs8y|i|ƒ}Wntj o tSnX|dj S(N(R RRR (RR R((s/sys/lib/python/weakref.pythas_keyCs  cCsdt|ƒS(Ns(tid(R((s/sys/lib/python/weakref.pyt__repr__JscCs t||i|ƒ|i||iiƒD]-}|ƒ}|dj o|i|ƒqqW|S(N(R R9R R'(RR(RR((s/sys/lib/python/weakref.pyR9½s  N(t__name__t __module__t__doc__RRRRRR!R$R R&R"R*R+R,R-R)R/R0R1R5R:R9(((s/sys/lib/python/weakref.pyR !s*              RcBs&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. R cCs"ti|||ƒ}||_|S(N(Rt__new__R (R3tobtcallbackR R((s/sys/lib/python/weakref.pyR>Òs cCstt|ƒi||ƒdS(N(tsuperRR(RR?R@R ((s/sys/lib/python/weakref.pyR×s(skey(R;R<R=t __slots__R>R(((s/sys/lib/python/weakref.pyRÆs cBs×eZdZdd„Zd„Zd„Zd„Zd„Zd„Z dd„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„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. cCsFh|_t|ƒd„}||_|dj o|i|ƒndS(NcSs(|ƒ}|dj o|i|=ndS(N(R R (tkRR((s/sys/lib/python/weakref.pyRès  (R RRR R5(RR6R((s/sys/lib/python/weakref.pyRæs  cCs|it|ƒ=dS(N(R R(RR ((s/sys/lib/python/weakref.pyt __delitem__ïscCs|it|ƒS(N(R R(RR ((s/sys/lib/python/weakref.pyRòscCsdt|ƒS(Ns(R(R((s/sys/lib/python/weakref.pyRõscCs||it||iƒ|iiƒD]-}|ƒ}|dj o|i|ƒqqW|S(N(R RGR R'(RR(RR((s/sys/lib/python/weakref.pyRGFs  cCsCx<|iiƒ\}}|ƒ}|dj o||fSqqdS(N(R R/R (RR R R((s/sys/lib/python/weakref.pyR/Ns   cGs|iit|ƒ|ŒS(N(R R0R(RR R((s/sys/lib/python/weakref.pyR0UscCs|iit||iƒ|ƒS(N(R R1RR(RR R%((s/sys/lib/python/weakref.pyR1XscKs•|i}|dj o]t|dƒpthƒ|ƒ}nx4|iƒD]"\}}||t||iƒs 4    ¥