Your IP : 18.216.134.4


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/weakref.pyc

�
�mec@s�dZddlZddlmZmZmZmZmZmZm	Z	ddl
mZddlm
Z
eefZdddd	d
dd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(tgetweakrefcounttgetweakrefstreftproxytCallableProxyTypet	ProxyTypet
ReferenceType(tWeakSet(tReferenceErrorRRRRtWeakKeyDictionaryRRRRt
ProxyTypestWeakValueDictionaryRcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e	Z
d�Zdd	�Z
d
�Zd�Zd�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�}||_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<WeakValueDictionary at %s>(tid(R((s/usr/lib64/python2.7/weakref.pyt__repr__LscCs t||j|�|j|<dS(N(tKeyedRefRR
(RRtvalue((s/usr/lib64/python2.7/weakref.pyt__setitem__OscCsOt�}x?|jj�D].\}}|�}|dk	r|||<qqW|S(N(RR
titemsR(RtnewRRR((s/usr/lib64/python2.7/weakref.pytcopyRs		cCskddlm}|j�}xH|jj�D]7\}}|�}|dk	r,|||||�<q,q,W|S(Ni����(tdeepcopy(R%R&t	__class__R
R#R(RtmemoR&R$RRR((s/usr/lib64/python2.7/weakref.pyt__deepcopy__\s	cCsGy|j|}Wntk
r%|SX|�}|dkr?|S|SdS(N(R
RR(RRtdefaultRR((s/usr/lib64/python2.7/weakref.pytgetes
	cCsUg}xH|jj�D]7\}}|�}|dk	r|j||f�qqW|S(N(R
R#Rtappend(RtLRRR((s/usr/lib64/python2.7/weakref.pyR#rs	ccsDx=|jj�D],}|�}|dk	r|j|fVqqWdS(N(R
t
itervaluesRR(RRR!((s/usr/lib64/python2.7/weakref.pyt	iteritemszs	cCs
|jj�S(N(R
titerkeys(R((s/usr/lib64/python2.7/weakref.pyR0�scCs
|jj�S(N(R
R0(R((s/usr/lib64/python2.7/weakref.pyt__iter__�scCs
|jj�S(s�Return 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.

        (R
R.(R((s/usr/lib64/python2.7/weakref.pyt
itervaluerefs�s
ccs;x4|jj�D]#}|�}|dk	r|VqqWdS(N(R
R.R(RRtobj((s/usr/lib64/python2.7/weakref.pyR.�s	cCs>x7|jj�\}}|�}|dk	r||fSqdS(N(R
tpopitemR(RRRR((s/usr/lib64/python2.7/weakref.pyR4�s
	cGs^y|jj|��}Wn"tk
r=|r7|dS�nX|dkrVt|�n|SdS(Ni(R
tpopRR(RRRR((s/usr/lib64/python2.7/weakref.pyR5�s
cCsMy|j|}Wn.tk
rAt||j|�|j|<|SX|�SdS(N(R
RR R(RRR*R((s/usr/lib64/python2.7/weakref.pyt
setdefault�s
cKs�|j}|dk	rrt|d�s9ti�|�}nx6|j�D]%\}}t||j|�||<qFWnt|�r�|j|�ndS(NR#(	R
RthasattrttypeR#R Rtlentupdate(RtdicttkwargstdRR((s/usr/lib64/python2.7/weakref.pyR:�s	 cCs
|jj�S(s~Return a list of 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.

        (R
tvalues(R((s/usr/lib64/python2.7/weakref.pyt	valuerefs�s
cCsIg}x<|jj�D]+}|�}|dk	r|j|�qqW|S(N(R
R>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&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(R8tobtcallbackRR((s/usr/lib64/python2.7/weakref.pyRD�s	cCstt|�j||�dS(N(tsuperR R(RRERFR((s/usr/lib64/python2.7/weakref.pyR�s(skey(R@RARBt	__slots__RDR(((s/usr/lib64/python2.7/weakref.pyR �s	cBs�eZdZdd�Zd�Zd�Zd�Zd�Zd�Z	e	Z
d�Zdd�Zd	�Z
d
�Zd�Zd�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.
    cCsDi|_t|�d�}||_|dk	r@|j|�ndS(NcSs&|�}|dk	r"|j|=ndS(N(RR
(tkRR((s/usr/lib64/python2.7/weakref.pyR�s	(R
RRRR:(RR;R((s/usr/lib64/python2.7/weakref.pyR�s
		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.pyR�scCsdt|�S(Ns<WeakKeyDictionary at %s>(R(R((s/usr/lib64/python2.7/weakref.pyRscCs||jt||j�<dS(N(R
RR(RRR!((s/usr/lib64/python2.7/weakref.pyR"scCsOt�}x?|jj�D].\}}|�}|dk	r|||<qqW|S(N(R	R
R#R(RR$RR!R((s/usr/lib64/python2.7/weakref.pyR%s		cCskddlm}|j�}xH|jj�D]7\}}|�}|dk	r,|||�||<q,q,W|S(Ni����(R&(R%R&R'R
R#R(RR(R&R$RR!R((s/usr/lib64/python2.7/weakref.pyR)s	cCs|jjt|�|�S(N(R
R+R(RRR*((s/usr/lib64/python2.7/weakref.pyR+scCs2yt|�}Wntk
r$dSX||jkS(Ni(Rt	TypeErrorR
(RRR((s/usr/lib64/python2.7/weakref.pyRs

cCs2yt|�}Wntk
r$dSX||jkS(Ni(RRKR
(RRR((s/usr/lib64/python2.7/weakref.pyR%s

cCsUg}xH|jj�D]7\}}|�}|dk	r|j||f�qqW|S(N(R
R#RR,(RR-RR!R((s/usr/lib64/python2.7/weakref.pyR#,s	ccsGx@|jj�D]/\}}|�}|dk	r||fVqqWdS(N(R
R/R(RRR!R((s/usr/lib64/python2.7/weakref.pyR/4s	cCs
|jj�S(s�Return an iterator that yields the 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.

        (R
R0(R((s/usr/lib64/python2.7/weakref.pytiterkeyrefs:s
ccs;x4|jj�D]#}|�}|dk	r|VqqWdS(N(R
R0R(RRR3((s/usr/lib64/python2.7/weakref.pyR0Fs	cCs
|j�S(N(R0(R((s/usr/lib64/python2.7/weakref.pyR1LscCs
|jj�S(N(R
R.(R((s/usr/lib64/python2.7/weakref.pyR.OscCs
|jj�S(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.

        (R
tkeys(R((s/usr/lib64/python2.7/weakref.pytkeyrefsRs
cCsIg}x<|jj�D]+}|�}|dk	r|j|�qqW|S(N(R
RMRR,(RR-RR((s/usr/lib64/python2.7/weakref.pyRM^s	cCs>x7|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|d�s9ti�|�}nx3|j�D]"\}}||t||j�<qFWnt|�r�|j|�ndS(NR#(	R
RR7R8R#RRR9R:(RR;R<R=RR!((s/usr/lib64/python2.7/weakref.pyR:ss	N(R@RARBRRRJRRR"R%RCR)R+RRR#R/RLR0R1R.RNRMR4R5R6R:(((s/usr/lib64/python2.7/weakref.pyR	�s0																					(RBRt_weakrefRRRRRRRt_weakrefsetRt
exceptionsRR
t__all__RR R	(((s/usr/lib64/python2.7/weakref.pyt<module>s4	�