Example #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
Example #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()
Example #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
Example #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
Example #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
    def iterkeys(self):
        with _IterationGuard(self):
            for wr in self.data.iterkeys():
                obj = wr()
                if obj is not None:
                    yield obj

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

        return
Example #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
    def iteritems(self):
        with _IterationGuard(self):
            for wr, value in self.data.iteritems():
                key = wr()
                if key is not None:
                    yield (key, value)

        return
Example #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
Example #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
Example #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
Example #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
Example #14
0
    def iterkeys(self):
        with _IterationGuard(self):
            for wr in self.data.iterkeys():
                obj = wr()
                if obj is not None:
                    yield obj

        return
Example #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
Example #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
Example #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
Example #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
Example #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()
Example #20
0
File: weakref.py Project: 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()
Example #21
0
 def itervalues(self):
     with _IterationGuard(self):
         for value in self.data.itervalues():
             yield value
Example #22
0
 def iterkeys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Example #23
0
File: weakref.py Project: 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
Example #24
0
 async def _do_call(_coro):
     with _IterationGuard(self):
         await _coro
Example #25
0
 def keys(self):
     with _IterationGuard(self):
         for (k, wr) in self.data.items():
             while wr() is not None:
                 yield k
Example #26
0
 def values(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             if wr() is not None:
                 yield value
Example #27
0
 def keys(self):
     with _IterationGuard(self):
         for wr in self.data:
             obj = wr()
             if obj is not None:
                 yield obj
Example #28
0
 def values(self):
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
Example #29
0
File: weakref.py Project: AbuzzT/BR
 def keys(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k
Example #30
0
File: weakref.py Project: AbuzzT/BR
 def values(self):
     with _IterationGuard(self):
         for wr, value in self.data.items():
             if wr() is not None:
                 yield value
Example #31
0
File: weakref.py Project: AbuzzT/BR
 def keys(self):
     with _IterationGuard(self):
         for wr in self.data:
             obj = wr()
             if obj is not None:
                 yield obj
Example #32
0
File: weakref.py Project: AbuzzT/BR
 def values(self):
     with _IterationGuard(self):
         for wr in self.data.values():
             obj = wr()
             if obj is not None:
                 yield obj
 def iterkeys(self):
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Example #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)
Example #35
0
 def iterkeys(self):
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
Example #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)
Example #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
Example #38
0
 def iterkeys(self):
     if self._pending_removals:
         self._commit_removals()
     with _IterationGuard(self):
         for k in self.data.iterkeys():
             yield k
 def itervaluerefs(self):
     with _IterationGuard(self):
         for wr in self.data.itervalues():
             yield wr
Example #40
0
 def values(self):
     with _IterationGuard(self):
         for (wr, value) in self.data.items():
             while wr() is not None:
                 yield value
 def iterkeyrefs(self):
     with _IterationGuard(self):
         for wr in self.data.iterkeys():
             yield wr
Example #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
 def itervalues(self):
     with _IterationGuard(self):
         for value in self.data.itervalues():
             yield value
Example #44
0
 def keys(self):
     with _IterationGuard(self):
         for k, wr in self.data.items():
             if wr() is not None:
                 yield k