nfc @sdZddlZddlmZmZmZmZmZmZm Z ddl m Z ddl m Z eefZdddd 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 ReferenceType(tWeakSet(tReferenceErrorRRRRtWeakKeyDictionaryRRRRt ProxyTypestWeakValueDictionaryRcBseZdZdZdZdZdZdZdZdZ e Z dZ dd Z d Zd Zd Zd ZdZdZdZdZddZddZdZdZRS(sMapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore cOs5t|d}||_tjj|||dS(NcSs)|}|dk r%|j|j=ndS(N(tNonetdatatkey(twrtselfreftself((s/usr/lib64/python2.7/weakref.pytremove0s  (Rt_removetUserDictt__init__(RtargstkwR((s/usr/lib64/python2.7/weakref.pyR/s cCs0|j|}|dkr(t|n|SdS(N(R R tKeyError(RRto((s/usr/lib64/python2.7/weakref.pyt __getitem__7s  cCs3y|j|}Wntk r(tSX|dk S(N(R RtFalseR (RRR((s/usr/lib64/python2.7/weakref.pyt __contains__>s  cCs3y|j|}Wntk r(tSX|dk S(N(R RRR (RRR((s/usr/lib64/python2.7/weakref.pythas_keyEs  cCsdt|S(Ns(tid(R((s/usr/lib64/python2.7/weakref.pyt__repr__LscCs t||j||j|x7|jj\}}|}|dk r||fSqdS(N(R tpopitemR (RRRR((s/usr/lib64/python2.7/weakref.pyR4s   cGs^y|jj|}Wn"tk r=|r7|dSnX|dkrVt|n|SdS(Ni(R tpopRR (RRRR((s/usr/lib64/python2.7/weakref.pyR5s   cCsMy|j|}Wn.tk rAt||j||j|<|SX|SdS(N(R RR R(RRR*R((s/usr/lib64/python2.7/weakref.pyt setdefaults  cKs|j}|dk rrt|ds9ti|}nx6|jD]%\}}t||j|||R R,(RR-RR((s/usr/lib64/python2.7/weakref.pyR>s   N(t__name__t __module__t__doc__RRRRRR"R%t__copy__R)R R+R#R/R0R1R2R.R4R5R6R:R?R>(((s/usr/lib64/python2.7/weakref.pyR #s.              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(R8tobtcallbackRR((s/usr/lib64/python2.7/weakref.pyRDs cCstt|j||dS(N(tsuperR R(RRERFR((s/usr/lib64/python2.7/weakref.pyRs(skey(R@RARBt __slots__RDR(((s/usr/lib64/python2.7/weakref.pyR s cBseZdZddZdZdZdZdZdZ e Z dZ ddZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZddZddZRS(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. cCsDi|_t|d}||_|dk r@|j|ndS(NcSs&|}|dk r"|j|=ndS(N(R R (tkRR((s/usr/lib64/python2.7/weakref.pyRs  (R RRR R:(RR;R((s/usr/lib64/python2.7/weakref.pyRs    cCs|jt|=dS(N(R R(RR((s/usr/lib64/python2.7/weakref.pyt __delitem__scCs|jt|S(N(R R(RR((s/usr/lib64/python2.7/weakref.pyRscCsdt|S(Ns(R(R((s/usr/lib64/python2.7/weakref.pyRscCs||jt||jx7|jj\}}|}|dk r||fSqdS(N(R R4R (RRR!R((s/usr/lib64/python2.7/weakref.pyR4fs   cGs|jjt||S(N(R R5R(RRR((s/usr/lib64/python2.7/weakref.pyR5mscCs|jjt||j|S(N(R R6RR(RRR*((s/usr/lib64/python2.7/weakref.pyR6pscKs|j}|dk rot|ds9ti|}nx3|jD]"\}}||t||js 4