Exemplo n.º 1
0
 def keys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k
Exemplo n.º 2
0
    def iter_instances(self):
        """Iterate over the stored objects

        .. seealso:: :meth:`pydispatch.utils.WeakMethodContainer.iter_instances`
        """
        with _IterationGuard(self):
            yield from super().iter_instances()
Exemplo n.º 3
0
 def keys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k
Exemplo n.º 4
0
 def items(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k, wr in list(self.data.items()):
             v = wr()
             if v is not None:
                 yield k, v
Exemplo n.º 5
0
 def iteritems(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for wr in self.data.itervalues():
             value = wr()
             if value is not None:
                 yield wr.key, value
Exemplo n.º 6
0
    def iterkeys(self):
        with _IterationGuard(self):
            for wr in self.data.iterkeys():
                obj = wr()
                if obj is not None:
                    yield obj

        return
Exemplo n.º 7
0
    def iteritems(self):
        with _IterationGuard(self):
            for wr in self.data.itervalues():
                value = wr()
                if value is not None:
                    yield (wr.key, value)

        return
Exemplo n.º 8
0
 def values(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 9
0
    def iteritems(self):
        with _IterationGuard(self):
            for wr, value in self.data.iteritems():
                key = wr()
                if key is not None:
                    yield (key, value)

        return
Exemplo n.º 10
0
    def iteritems(self):
        with _IterationGuard(self):
            for wr, value in self.data.iteritems():
                key = wr()
                if key is not None:
                    yield (key, value)

        return
Exemplo n.º 11
0
    def iteritems(self):
        with _IterationGuard(self):
            for wr in self.data.itervalues():
                value = wr()
                if value is not None:
                    yield (wr.key, value)

        return
Exemplo n.º 12
0
 def iteritems(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for wr in self.data.itervalues():
             value = wr()
             if value is not None:
                 yield wr.key, value
Exemplo n.º 13
0
 def copy(self):
     new = WeakKeyDictionary()
     with _IterationGuard(self):
         for key, value in self.data.items():
             o = key()
             if o is not None:
                 new[o] = value
     return new
Exemplo n.º 14
0
    def iterkeys(self):
        with _IterationGuard(self):
            for wr in self.data.iterkeys():
                obj = wr()
                if obj is not None:
                    yield obj

        return
Exemplo n.º 15
0
 def itervalues(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for wr in self.data.itervalues():
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 16
0
 def __deepcopy__(self, memo):
     from copy import deepcopy
     new = self.__class__()
     with _IterationGuard(self):
         for key, value in self.data.items():
             o = key()
             if o is not None:
                 new[o] = deepcopy(value, memo)
     return new
Exemplo n.º 17
0
 def copy(self):
     if self._pending_removals:
         self._commit_removals()
     new = WeakValueDictionary()
     with _IterationGuard(self):
         for key, wr in self.data.items():
             o = wr()
             if o is not None:
                 new[key] = o
     return new
Exemplo n.º 18
0
 def __deepcopy__(self, memo):
     from copy import deepcopy
     if self._pending_removals:
         self._commit_removals()
     new = self.__class__()
     with _IterationGuard(self):
         for key, wr in self.data.items():
             o = wr()
             if o is not None:
                 new[deepcopy(key, memo)] = o
     return new
Exemplo n.º 19
0
    def itervaluerefs(self):
        """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.

        """
        with _IterationGuard(self):
            yield from self.data.values()
Exemplo n.º 20
0
Arquivo: weakref.py Projeto: AbuzzT/BR
    def itervaluerefs(self):
        """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.

        """
        with _IterationGuard(self):
            yield from self.data.values()
Exemplo n.º 21
0
 def itervalues(self):
     with _IterationGuard(self):
         for value in self.data.itervalues():
             yield value
Exemplo n.º 22
0
 def iterkeys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Exemplo n.º 23
0
Arquivo: weakref.py Projeto: AbuzzT/BR
 def items(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             v = wr()
             if v is not None:
                 yield k, v
Exemplo n.º 24
0
 async def _do_call(_coro):
     with _IterationGuard(self):
         await _coro
Exemplo n.º 25
0
 def keys(self):
     with _IterationGuard(self):
         for (k, wr) in self.data.items():
             while wr() is not None:
                 yield k
Exemplo n.º 26
0
 def values(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             if wr() is not None:
                 yield value
Exemplo n.º 27
0
 def keys(self):
     with _IterationGuard(self):
         for wr in self.data:
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 28
0
 def values(self):
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 29
0
Arquivo: weakref.py Projeto: AbuzzT/BR
 def keys(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k
Exemplo n.º 30
0
Arquivo: weakref.py Projeto: AbuzzT/BR
 def values(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             if wr() is not None:
                 yield value
Exemplo n.º 31
0
Arquivo: weakref.py Projeto: AbuzzT/BR
 def keys(self):
     with _IterationGuard(self):
         for wr in self.data:
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 32
0
Arquivo: weakref.py Projeto: AbuzzT/BR
 def values(self):
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
Exemplo n.º 33
0
 def iterkeys(self):
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Exemplo n.º 34
0
 def items(self):
     with _IterationGuard(self):
         for (wr, value) in self.data.items():
             key = wr()
             while key is not None:
                 yield (key, value)
Exemplo n.º 35
0
 def iterkeys(self):
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Exemplo n.º 36
0
 def items(self):
     with _IterationGuard(self):
         for (k, wr) in self.data.items():
             v = wr()
             while v is not None:
                 yield (k, v)
Exemplo n.º 37
0
 def items(self):
     with _IterationGuard(self):
         for wr, value in list(self.data.items()):
             key = wr()
             if key is not None:
                 yield key, value
Exemplo n.º 38
0
 def iterkeys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Exemplo n.º 39
0
 def itervaluerefs(self):
     with _IterationGuard(self):
         for wr in self.data.itervalues():
             yield wr
Exemplo n.º 40
0
 def values(self):
     with _IterationGuard(self):
         for (wr, value) in self.data.items():
             while wr() is not None:
                 yield value
Exemplo n.º 41
0
 def iterkeyrefs(self):
     with _IterationGuard(self):
         for wr in self.data.iterkeys():
             yield wr
Exemplo n.º 42
0
 def items(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             v = wr()
             if v is not None:
                 yield k, v
Exemplo n.º 43
0
 def itervalues(self):
     with _IterationGuard(self):
         for value in self.data.itervalues():
             yield value
Exemplo n.º 44
0
 def keys(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k