%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/weakref.cpython-38.pyc

U

naS
@sdZddlmZmZmZmZmZmZmZm	Z	ddl
mZmZddl
Z
ddlZddlZeefZddddd	d
ddd
ddddg
ZGdddeZGddde
jZGdddeZGdd	d	e
jZGdddZdS)z{Weak reference support for Python.

This module is an implementation of PEP 205:

http://www.python.org/dev/peps/pep-0205/
)getweakrefcountgetweakrefsrefproxyCallableProxyType	ProxyType
ReferenceType_remove_dead_weakref)WeakSet_IterationGuardNrrrrWeakKeyDictionaryrrr
ProxyTypesWeakValueDictionaryr

WeakMethodfinalizecsDeZdZdZdZdddZfddZdd	Zd
dZe	j
Z
ZS)
rz
    A custom `weakref.ref` subclass which simulates a weak reference to
    a bound method, working around the lifetime problem of bound methods.
    )	_func_ref
_meth_type_alive__weakref__Ncs~z|j}|j}Wn(tk
r8tdt|dYnXfdd}t|||}t|||_t||_	d|_
t||S)Nz)argument should be a bound method, not {}cs&}|jr"d|_dk	r"|dSNF)r)argselfcallbackself_wr#/usr/local/lib/python3.8/weakref.py_cb3s
zWeakMethod.__new__.<locals>._cbT)__self____func__AttributeError	TypeErrorformattyper__new__rrr)clsmethrobjfuncrrrrrr$,s 

zWeakMethod.__new__cs2t}|}|dks"|dkr&dS|||SN)super__call__rr)rr'r(	__class__rrr+Bs

zWeakMethod.__call__cCs:t|tr6|jr|js||kSt||o4|j|jkSdSr)
isinstancerrr__eq__rrotherrrrr/Is

zWeakMethod.__eq__cCs:t|tr6|jr|js||k	St||p4|j|jkSdSNT)r.rrr__ne__rr0rrrr3Ps

zWeakMethod.__ne__)N)__name__
__module____qualname____doc__	__slots__r$r+r/r3r__hash__
__classcell__rrr,rr$s
c@seZdZdZd,ddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZeZ
ddZd-ddZddZddZeZddZd d!Zd"d#Zd$d%Zd.d&d'Zd/d(d)Zd*d+ZdS)0rzMapping class that references values weakly.

    Entries in the dictionary will be discarded when no strong
    reference to the value exists anymore
    rcKs>t|tfdd}||_g|_t|_i|_|j|f|dS)NcSs6|}|dk	r2|jr$|j|jn||j|jdSr))
_iterating_pending_removalsappendkeydata)wrselfref_atomic_removalrrrrremovegs
z,WeakValueDictionary.__init__.<locals>.remove)rr	_remover<setr;r?update)rr1kwrCrrr__init__fs	zWeakValueDictionary.__init__cCs(|j}|j}|r$|}t||qdSr))r<r?popr	)rldr>rrr_commit_removalsws
z$WeakValueDictionary._commit_removalscCs4|jr||j|}|dkr,t|n|SdSr)r<rLr?KeyErrorrr>orrr__getitem__s
zWeakValueDictionary.__getitem__cCs|jr||j|=dSr))r<rLr?rr>rrr__delitem__szWeakValueDictionary.__delitem__cCs|jr|t|jSr))r<rLlenr?rrrr__len__szWeakValueDictionary.__len__cCs>|jr|z|j|}Wntk
r4YdSX|dk	SrrMrOrrr__contains__sz WeakValueDictionary.__contains__cCsd|jjt|fSNz<%s at %#x>r-r4idrUrrr__repr__szWeakValueDictionary.__repr__cCs&|jr|t||j||j|<dSr))r<rLKeyedRefrDr?rr>valuerrr__setitem__szWeakValueDictionary.__setitem__c	CsV|jr|t}t|0|jD]\}}|}|dk	r(|||<q(W5QRX|Sr))r<rLrrr?items)rnewr>r@rPrrrcopys
zWeakValueDictionary.copyc	Csjddlm}|jr||}t|6|jD]$\}}|}|dk	r6|||||<q6W5QRX|SNr)deepcopy)rbrdr<rLr-rr?r`)rmemordrar>r@rPrrr__deepcopy__s
z WeakValueDictionary.__deepcopy__NcCsP|jr|z|j|}Wntk
r4|YSX|}|dkrH|S|SdSr)rM)rr>defaultr@rPrrrgets
zWeakValueDictionary.getc	csR|jr|t|2|jD] \}}|}|dk	r"||fVq"W5QRXdSr)r<rLrr?r`)rkr@vrrrr`s
zWeakValueDictionary.itemsc	csJ|jr|t|*|jD]\}}|dk	r"|Vq"W5QRXdSr)ri)rrjr@rrrkeyss

zWeakValueDictionary.keysc	cs6|jr|t||jEdHW5QRXdS)aReturn 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.

        Nr<rLrr?valuesrUrrr
itervaluerefss

z!WeakValueDictionary.itervaluerefsc	csJ|jr|t|*|jD]}|}|dk	r"|Vq"W5QRXdSr)rmrr@r'rrrrns
zWeakValueDictionary.valuescCs8|jr||j\}}|}|dk	r||fSqdSr))r<rLr?popitem)rr>r@rPrrrrqszWeakValueDictionary.popitemcGs`|jr|z|j|}Wntk
r8d}YnX|dkrX|rN|dSt|n|SdS)Nr)r<rLr?rIrN)rr>argsrPrrrrIs

zWeakValueDictionary.popcCs`z|j|}Wntk
r(d}YnX|dkrX|jr@|t||j||j|<|S|SdSr))r?rNr<rLr\rD)rr>rgrPrrr
setdefaults
zWeakValueDictionary.setdefaultcKsz|jr||j}|dk	rRt|ds.t|}|D]\}}t||j|||<q6|D]\}}t||j|||<qZdSNr`)r<rLr?hasattrdictr`r\rD)rr1kwargsrKr>rPrrrrFs
zWeakValueDictionary.updatecCs|jr|t|jS)a~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<rLlistr?rnrUrrr	valuerefs(s
zWeakValueDictionary.valuerefs)r)N)N)N)r4r5r6r7rHrLrQrSrVrWr[r_rb__copy__rfrhr`rl__iter__rornrqrIrsrFryrrrrrZs.
			
			

cs,eZdZdZdZddZfddZZS)r\a[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>cCst|||}||_|Sr))rr$r>)r#obrr>rrrrr$CszKeyedRef.__new__cst||dSr))r*rH)rr}rr>r,rrrHHszKeyedRef.__init__)r4r5r6r7r8r$rHr:rrr,rr\7s	r\c@seZdZdZd+ddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZeZ
ddZd,ddZddZddZddZeZdd Zd!d"Zd#d$Zd%d&Zd-d'd(Zd.d)d*ZdS)/ra 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.
    NcCsFi|_t|fdd}||_g|_t|_d|_|dk	rB||dS)NcSs.|}|dk	r*|jr"|j|n|j|=dSr))r;r<r=r?)rjrArrrrrCYs
z*WeakKeyDictionary.__init__.<locals>.removeF)r?rrDr<rEr;
_dirty_lenrF)rrvrCrrrrHWszWeakKeyDictionary.__init__cCs:|j}|j}|r6z||=Wqtk
r2YqXqdSr))r<r?rIrN)rrJrKrrrrLhsz"WeakKeyDictionary._commit_removalscs&|jfdd|jD|_d|_dS)Ncsg|]}|kr|qSrr).0rjrKrr
<listcomp>wsz5WeakKeyDictionary._scrub_removals.<locals>.<listcomp>F)r?r<r~rUrrr_scrub_removalsusz!WeakKeyDictionary._scrub_removalscCsd|_|jt|=dSr2)r~r?rrRrrrrSzszWeakKeyDictionary.__delitem__cCs|jt|Sr))r?rrRrrrrQ~szWeakKeyDictionary.__getitem__cCs(|jr|jr|t|jt|jSr))r~r<rrTr?rUrrrrVszWeakKeyDictionary.__len__cCsd|jjt|fSrXrYrUrrrr[szWeakKeyDictionary.__repr__cCs||jt||j<dSr))r?rrDr]rrrr_szWeakKeyDictionary.__setitem__c	CsHt}t|0|jD]\}}|}|dk	r|||<qW5QRX|Sr))rrr?r`)rrar>r^rPrrrrbs
zWeakKeyDictionary.copyc	Cs\ddlm}|}t|6|jD]$\}}|}|dk	r(|||||<q(W5QRX|Src)rbrdr-rr?r`)rrerdrar>r^rPrrrrfs
zWeakKeyDictionary.__deepcopy__cCs|jt||Sr))r?rhrrr>rgrrrrhszWeakKeyDictionary.getcCs.zt|}Wntk
r"YdSX||jkSr)rr!r?)rr>r@rrrrWs
zWeakKeyDictionary.__contains__c	csDt|2|jD] \}}|}|dk	r||fVqW5QRXdSr)rr?r`)rr@r^r>rrrr`s

zWeakKeyDictionary.itemsc	cs8t|&|jD]}|}|dk	r|VqW5QRXdSr))rr?rprrrrls


zWeakKeyDictionary.keysc	cs<t|*|jD]\}}|dk	r|VqW5QRXdSr)r)rr@r^rrrrns

zWeakKeyDictionary.valuescCs
t|jS)azReturn 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.

        )rxr?rUrrrkeyrefss
zWeakKeyDictionary.keyrefscCs0d|_|j\}}|}|dk	r||fSqdSr2)r~r?rq)rr>r^rPrrrrqs
zWeakKeyDictionary.popitemcGsd|_|jjt|f|Sr2)r~r?rIr)rr>rrrrrrIszWeakKeyDictionary.popcCs|jt||j|Sr))r?rsrrDrrrrrsszWeakKeyDictionary.setdefaultcKs\|j}|dk	rFt|ds$ti|}|D]\}}||t||j<q,t|rX||dSrt)r?rur#r`rrDrTrF)rrvrwrKr>r^rrrrFs
zWeakKeyDictionary.update)N)N)N)N)r4r5r6r7rHrLrrSrQrVr[r_rbrzrfrhrWr`rlr{rnrrqrIrsrFrrrrrLs.


	


c@seZdZdZdZiZdZeZ	dZ
dZGdddZddZ
de
_dd
dZdd
ZddZeddZeddZejddZddZeddZeddZd	S)raClass for finalization of weakrefable objects

    finalize(obj, func, *args, **kwargs) returns a callable finalizer
    object which will be called when obj is garbage collected. The
    first time the finalizer is called it evaluates func(*arg, **kwargs)
    and returns the result. After this the finalizer is dead, and
    calling it just returns None.

    When the program exits any remaining finalizers for which the
    atexit attribute is true will be run in reverse order of creation.
    By default atexit is true.
    rFc@seZdZdZdS)zfinalize._Info)weakrefr(rrrwatexitindexN)r4r5r6r8rrrr_InfosrcOs>t|dkr|^}}}}n|s(tdnd|krDtdt|d|d}t|dkr~|^}}}ddl}|jdtdd	nFd
|krtdt|d|d
}|^}}ddl}|jdtdd	t|}|jsddl}|	|j
dt_|}t
|||_||_||_|pd|_d|_t|j|_||j|<dt_dS)
Nz<descriptor '__init__' of 'finalize' object needs an argumentr(z9finalize expected at least 2 positional arguments, got %drz0Passing 'func' as keyword argument is deprecated)
stacklevelr'z/Passing 'obj' as keyword argument is deprecatedT)rTr!rIwarningswarnDeprecationWarningtuple_registered_with_atexitrregister	_exitfuncrrrrr(rrrwnext_index_iterr	_registry_dirty)rrrwrr'r(rrinforrrrHsR






zfinalize.__init__z&($self, obj, func, /, *args, **kwargs)NcCs0|j|d}|r,|js,|j|j|jp(iSdS)zZIf alive then mark as dead and return func(*args, **kwargs);
        otherwise return NoneN)rrI	_shutdownr(rrrw)r_rrrrr+1s
zfinalize.__call__cCsH|j|}|o|}|dk	rD|j|drD||j|j|jp@ifSdS)z^If alive then mark as dead and return (obj, func, args, kwargs);
        otherwise return NoneN)rrhrrIr(rrrwrrr'rrrdetach8szfinalize.detachcCs:|j|}|o|}|dk	r6||j|j|jp2ifSdS)zMIf alive then return (obj, func, args, kwargs);
        otherwise return NoneN)rrhrr(rrrwrrrrpeek@sz
finalize.peekcCs
||jkS)zWhether finalizer is alive)rrUrrraliveHszfinalize.alivecCs|j|}t|o|jS)z*Whether finalizer should be called at exitrrhboolr)rrrrrrMszfinalize.atexitcCs|j|}|rt||_dSr)r)rr^rrrrrSscCs^|j|}|o|}|dkr6dt|jt|fSdt|jt|t|jt|fSdS)Nz<%s object at %#x; dead>z!<%s object at %#x; for %r at %#x>)rrhrr#r4rZrrrrr[Yszfinalize.__repr__cCs2dd|jD}|jddddd|DS)NcSsg|]\}}|jr||fqSr)rrfirrrresz-finalize._select_for_exit.<locals>.<listcomp>cSs
|djS)Nr)r)itemrrr<lambda>fz+finalize._select_for_exit.<locals>.<lambda>r|cSsg|]\}}|qSrrrrrrrgs)rr`sort)r%Lrrr_select_for_exitbszfinalize._select_for_exitcCsd}z|jrddl}|r(d}|d}|dks:tjrH|}dt_|sNq|	}z
|Wn"t
k
rtjt
YnX||jks,tq,W5dt_|r|XdS)NFTr)rrenablergc	isenableddisablerrrI	Exceptionsys
excepthookexc_infoAssertionError)r%reenable_gcrpendingrrrrris,
zfinalize._exitfunc)N)r4r5r6r7r8rr	itertoolscountrrrrrH__text_signature__r+rrpropertyrrsetterr[classmethodrrrrrrrs0*



	
)r7_weakrefrrrrrrrr	_weakrefsetr
r_collections_abcrrr
__all__rMutableMappingrr\rrrrrr<module>s0(
6^

Zerion Mini Shell 1.0