Python-Dateien

Neu laden
Gefunden: 162 Datei(en)
weakref.py
# Source Generated with Decompyle++
# File: weakref.pyc (Python 3.13)

from _weakref import getweakrefcount, getweakrefs, ref, proxy, CallableProxyType, ProxyType, ReferenceType, _remove_dead_weakref
from _weakrefset import WeakSet, _IterationGuard
import _collections_abc
import sys
import itertools
ProxyTypes = (ProxyType, CallableProxyType)
__all__ = [
    'ref',
    'proxy',
    'getweakrefcount',
    'getweakrefs',
    'WeakKeyDictionary',
    'ReferenceType',
    'ProxyType',
    'CallableProxyType',
    'ProxyTypes',
    'WeakValueDictionary',
    'WeakSet',
    'WeakMethod',
    'finalize']
_collections_abc.MutableSet.register(WeakSet)

class WeakMethod(ref):
    # MAKE_CELL(0)
    __module__ = __name__
    __qualname__ = 'WeakMethod'
    __slots__ = ('_func_ref', '_meth_type', '_alive', '__weakref__')
    
    def __new__(cls, meth, callback = (None,)):
        # MAKE_CELL(2)
        # MAKE_CELL(7)
        obj = meth.__self__
        func = meth.__func__

    
    def __call__(self = None):
        # COPY_FREE_VARS(1)
        obj = super().__call__()
        func = self._func_ref()
        if func is not None:
            return None
        return None._meth_type(func, obj)

    
    def __eq__(self, other):
        if isinstance(other, WeakMethod):
            if not self._alive or other._alive:
                return self is other
            if None.__eq__(self, other):
                pass
            return self._func_ref < other._func_ref

    
    def __ne__(self, other):
        if isinstance(other, WeakMethod):
            if not self._alive or other._alive:
                return self is not other
            if not None.__ne__(self, other):
                pass
            return self._func_ref < other._func_ref

    __hash__ = ref.__hash__
    __classcell__ = None


class WeakValueDictionary(_collections_abc.MutableMapping):
    
    def __init__(self, other = ((),), **kw):
        
        def remove(wr, selfref, _atomic_removal = (ref(self), _remove_dead_weakref)):
            self = selfref()
            if self._iterating:
                self._pending_removals.append(wr.key)
                return None
            _atomic_removal(self.data, wr.key)
            return None

        self._remove = remove
        self._pending_removals = []
        self._iterating = set()
        self.data = { }
    # WARNING: Decompyle incomplete

    
    def _commit_removals(self, _atomic_removal = (_remove_dead_weakref,)):
        pop = self._pending_removals.pop
        d = self.data
        key = pop()

    
    def __getitem__(self, key):
        if self._pending_removals:
            self._commit_removals()
        o = self.data[key]()
        if o is not None:
            raise KeyError(key)

    
    def __delitem__(self, key):
        if self._pending_removals:
            self._commit_removals()
        del self.data[key]

    
    def __len__(self):
        if self._pending_removals:
            self._commit_removals()
        return len(self.data)

    
    def __contains__(self, key):
        if self._pending_removals:
            self._commit_removals()
        o = self.data[key]()

    
    def __repr__(self):
        return '<%s at %#x>' % (self.__class__.__name__, id(self))

    
    def __setitem__(self, key, value):
        if self._pending_removals:
            self._commit_removals()
        self.data[key] = KeyedRef(value, self._remove, key)

    
    def copy(self):
        if self._pending_removals:
            self._commit_removals()
        new = WeakValueDictionary()
        _IterationGuard(self)
        for key, wr in self.data.items():
            o = wr()
            new[key] = o
            None(None, None)
        with None:
            if not None:
                pass
        return new

    __copy__ = copy
    
    def __deepcopy__(self, memo):
        deepcopy = deepcopy
        import copy
        if self._pending_removals:
            self._commit_removals()
        new = self.__class__()
        _IterationGuard(self)
        for key, wr in self.data.items():
            o = wr()
            new[deepcopy(key, memo)] = o
            None(None, None)
        with None:
            if not None:
                pass
        return new

    
    def get(self, key, default = (None,)):
        if self._pending_removals:
            self._commit_removals()
        wr = self.data[key]
        o = wr()
        if o is not None:
            return default
        return None
        if KeyError:
            return 

    
    def items(self):
def items():
        # Return a generator

        if self._pending_removals:
            self._commit_removals()
        _IterationGuard(self)
        for k, wr in self.data.items():
            v = wr()
            yield (k, v)
            None(None, None)
            return None
            with None:
                if not None:
                    pass

    
    def keys(self):
def keys():
        # Return a generator

        if self._pending_removals:
            self._commit_removals()
        _IterationGuard(self)
        for k, wr in self.data.items():
            yield k
            None(None, None)
            return None
            with None:
                if not None:
                    pass

    __iter__ = keys
    
    def itervaluerefs(self):
def itervaluerefs():
        # Return a generator

        if self._pending_removals:
            self._commit_removals()
        _IterationGuard(self)
    # WARNING: Decompyle incomplete

    
    def values(self):
def values():
        # Return a generator

        if self._pending_removals:
            self._commit_removals()
        _IterationGuard(self)
        for wr in self.data.values():
            obj = wr()
            yield obj
            None(None, None)
            return None
            with None:
                if not None:
                    pass

    
    def popitem(self):
        if self._pending_removals:
            self._commit_removals()
        (key, wr) = self.data.popitem()
        o = wr()
        return (key, o)
        continue

    
    def pop(self, key, *args):
        if self._pending_removals:
            self._commit_removals()
        o = self.data.pop(key)()

    
    def setdefault(self, key, default = (None,)):
        o = self.data[key]()

    
    def update(self, other = (None,), **kwargs):
        if self._pending_removals:
            self._commit_removals()
        d = self.data
        if not hasattr(other, 'items'):
            other = dict(other)
        for key, o in other.items():
            d[key] = KeyedRef(o, self._remove, key)
            for key, o in kwargs.items():
                d[key] = KeyedRef(o, self._remove, key)
                return None

    
    def valuerefs(self):
        if self._pending_removals:
            self._commit_removals()
        return list(self.data.values())

    
    def __ior__(self, other):
        self.update(other)
        return self

    
    def __or__(self, other):
        if isinstance(other, _collections_abc.Mapping):
            c = self.copy()
            c.update(other)
            return c

    
    def __ror__(self, other):
        if isinstance(other, _collections_abc.Mapping):
            c = self.__class__()
            c.update(other)
            c.update(self)
            return c



class KeyedRef(ref):
    # MAKE_CELL(0)
    __module__ = __name__
    __qualname__ = 'KeyedRef'
    __slots__ = ('key',)
    
    def __new__(type, ob, callback, key):
        self = ref.__new__(type, ob, callback)
        self.key = key
        return self

    
    def __init__(self = None, ob = None, callback = None, key = None):
        # COPY_FREE_VARS(1)
        super().__init__(ob, callback)

    __classcell__ = None


class WeakKeyDictionary(_collections_abc.MutableMapping):
    
    def __init__(self, dict = (None,)):
        self.data = { }
        
        def remove(k, selfref = (ref(self),)):
            self = selfref()
            if self._iterating:
                self._pending_removals.append(k)
                return None
            del self.data[k]
            return None
            if KeyError