ž «ÿfç,c @sÛdZddlmZmZmZmZmZmZmZddl m Z m Z ddl Z eefZ ddddd d d d d ddg ZGdd„de jƒZGdd„deƒZGdd „d e jƒZdS(u{Weak reference support for Python. This module is an implementation of PEP 205: http://www.python.org/dev/peps/pep-0205/ i(ugetweakrefcountu getweakrefsurefuproxyuCallableProxyTypeu ProxyTypeu ReferenceType(uWeakSetu_IterationGuardNurefuproxyugetweakrefcountu getweakrefsuWeakKeyDictionaryu ReferenceTypeu ProxyTypeuCallableProxyTypeu ProxyTypesuWeakValueDictionaryuWeakSetcBs|EeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z e Z dd„Zd*dd„Zdd„Zdd„ZeZdd„Zdd„Zd d!„Zd"d#„Zd*d$d%„Zd*d&d'„Zd(d)„Zd*S(+uWeakValueDictionaryu›Mapping class that references values weakly. Entries in the dictionary will be discarded when no strong reference to the value exists anymore cOsTt|ƒdd„}||_g|_tƒ|_i|_}|j||ŽdS(NcSsH|ƒ}|dk rD|jr4|jj|jƒqD|j|j=ndS(N(uNoneu _iteratingu_pending_removalsuappendukeyudata(uwruselfrefuself((u,/opt/alt/python33/lib64/python3.3/weakref.pyuremove.s    u,WeakValueDictionary.__init__..remove(urefu_removeu_pending_removalsusetu _iteratingudatauupdate(uselfuargsukwuremoveud((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__init__-s     uWeakValueDictionary.__init__cCs0|j}|j}x|r+||jƒ=qWdS(N(u_pending_removalsudataupop(uselfulud((u,/opt/alt/python33/lib64/python3.3/weakref.pyu_commit_removals<s   u$WeakValueDictionary._commit_removalscCs3|j|ƒ}|dkr+t|ƒ‚n|SdS(N(udatauNoneuKeyError(uselfukeyuo((u,/opt/alt/python33/lib64/python3.3/weakref.pyu __getitem__Ds uWeakValueDictionary.__getitem__cCs$|jr|jƒn|j|=dS(N(u_pending_removalsu_commit_removalsudata(uselfukey((u,/opt/alt/python33/lib64/python3.3/weakref.pyu __delitem__Ks  uWeakValueDictionary.__delitem__cCst|jƒt|jƒS(N(ulenudatau_pending_removals(uself((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__len__PsuWeakValueDictionary.__len__c Cs7y|j|ƒ}Wntk r,dSYnX|dk S(NF(udatauKeyErroruFalseuNone(uselfukeyuo((u,/opt/alt/python33/lib64/python3.3/weakref.pyu __contains__Ss   u WeakValueDictionary.__contains__cCsdt|ƒS(Nu(uid(uself((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__repr__ZsuWeakValueDictionary.__repr__cCs6|jr|jƒnt||j|ƒ|j||EeZdZdZdZdd„Z‡fdd†Z‡S(uKeyedRefu[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. ukeycCs"tj|||ƒ}||_|S(N(urefu__new__ukey(utypeuobucallbackukeyuself((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__new__ís uKeyedRef.__new__cstƒj||ƒdS(N(usuperu__init__(uselfuobucallbackukey(u __class__(u,/opt/alt/python33/lib64/python3.3/weakref.pyu__init__òsuKeyedRef.__init__(ukey(u__name__u __module__u __qualname__u__doc__u __slots__u__new__u__init__(u __locals__((u __class__u,/opt/alt/python33/lib64/python3.3/weakref.pyuKeyedRefás uKeyedRefcBs|EeZdZdZd(dd„Zdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z e Z dd„Zd(dd„Zdd„Zdd„Zdd„ZeZdd„Zdd„Zd d!„Zd"d#„Zd(d$d%„Zd(d&d'„Zd(S()uWeakKeyDictionaryu‰ 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. cCs\i|_t|ƒdd„}||_g|_tƒ|_|dk rX|j|ƒndS(NcSsB|ƒ}|dk r>|jr1|jj|ƒq>|j|=ndS(N(uNoneu _iteratingu_pending_removalsuappendudata(ukuselfrefuself((u,/opt/alt/python33/lib64/python3.3/weakref.pyuremoves    u*WeakKeyDictionary.__init__..remove(udataurefu_removeu_pending_removalsusetu _iteratinguNoneuupdate(uselfudicturemove((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__init__s     uWeakKeyDictionary.__init__c CsI|j}|j}x0|rDy||jƒ=Wqtk r@YqXqWdS(N(u_pending_removalsudataupopuKeyError(uselfulud((u,/opt/alt/python33/lib64/python3.3/weakref.pyu_commit_removalss    u"WeakKeyDictionary._commit_removalscCs|jt|ƒ=dS(N(udatauref(uselfukey((u,/opt/alt/python33/lib64/python3.3/weakref.pyu __delitem__suWeakKeyDictionary.__delitem__cCs|jt|ƒS(N(udatauref(uselfukey((u,/opt/alt/python33/lib64/python3.3/weakref.pyu __getitem__!suWeakKeyDictionary.__getitem__cCst|jƒt|jƒS(N(ulenudatau_pending_removals(uself((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__len__$suWeakKeyDictionary.__len__cCsdt|ƒS(Nu(uid(uself((u,/opt/alt/python33/lib64/python3.3/weakref.pyu__repr__'suWeakKeyDictionary.__repr__cCs||jt||jƒx7|jjƒ\}}|ƒ}|dk r||fSqdS(N(udataupopitemuNone(uselfukeyuvalueuo((u,/opt/alt/python33/lib64/python3.3/weakref.pyupopitemls   uWeakKeyDictionary.popitemcGs|jjt|ƒ|ŒS(N(udataupopuref(uselfukeyuargs((u,/opt/alt/python33/lib64/python3.3/weakref.pyupopssuWeakKeyDictionary.popcCs|jjt||jƒ|ƒS(N(udatau setdefaulturefu_remove(uselfukeyudefault((u,/opt/alt/python33/lib64/python3.3/weakref.pyu setdefaultvsuWeakKeyDictionary.setdefaultcKs|j}|dk rot|dƒs9tiƒ|ƒ}nx3|jƒD]"\}}||t||jƒs4       À