Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
dbm.dumb._Database Class Reference
Inheritance diagram for dbm.dumb._Database:
Inheritance graph
[legend]
Collaboration diagram for dbm.dumb._Database:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getitem__
def __setitem__
def __delitem__
def keys
def items
def __contains__
def iterkeys
def __len__
def close
def pop
def popitem
def clear
def update
def setdefault
def get
def values
def __eq__
def __ne__
def __subclasshook__
def __subclasshook__
def __subclasshook__
def __new__
def __new__
def __new__
def register
def register
def register
def __instancecheck__
def __instancecheck__
def __instancecheck__
def __subclasscheck__
def __subclasscheck__
def __subclasscheck__
def __iter__

Static Public Attributes

 sync = _commit

Private Member Functions

def _update
def _commit
def _addval
def _setval
def _addkey
def _chmod

Private Attributes

 _mode
 _dirfile
 _datfile
 _bakfile
 _index

Static Private Attributes

 _os = _os
 _io = _io
 __iter__ = iterkeys
 __del__ = close

Detailed Description

Definition at line 34 of file dumb.py.


Constructor & Destructor Documentation

def dbm.dumb._Database.__init__ (   self,
  filebasename,
  mode 
)

Definition at line 47 of file dumb.py.

00047 
00048     def __init__(self, filebasename, mode):
00049         self._mode = mode
00050 
00051         # The directory file is a text file.  Each line looks like
00052         #    "%r, (%d, %d)\n" % (key, pos, siz)
00053         # where key is the string key, pos is the offset into the dat
00054         # file of the associated value's first byte, and siz is the number
00055         # of bytes in the associated value.
00056         self._dirfile = filebasename + '.dir'
00057 
00058         # The data file is a binary file pointed into by the directory
00059         # file, and holds the values associated with keys.  Each value
00060         # begins at a _BLOCKSIZE-aligned byte offset, and is a raw
00061         # binary 8-bit string value.
00062         self._datfile = filebasename + '.dat'
00063         self._bakfile = filebasename + '.bak'
00064 
00065         # The index is an in-memory dict, mirroring the directory file.
00066         self._index = None  # maps keys to (pos, siz) pairs
00067 
00068         # Mod by Jack: create data file if needed
00069         try:
00070             f = _io.open(self._datfile, 'r', encoding="Latin-1")
00071         except IOError:
00072             f = _io.open(self._datfile, 'w', encoding="Latin-1")
00073             self._chmod(self._datfile)
00074         f.close()
00075         self._update()

Here is the caller graph for this function:


Member Function Documentation

def dbm.dumb._Database.__contains__ (   self,
  key 
)

Reimplemented from _abcoll.Mapping.

Definition at line 217 of file dumb.py.

00217 
00218     def __contains__(self, key):
00219         if isinstance(key, str):
00220             key = key.encode('utf-8')
00221         return key in self._index

def dbm.dumb._Database.__delitem__ (   self,
  key 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 200 of file dumb.py.

00200 
00201     def __delitem__(self, key):
00202         if isinstance(key, str):
00203             key = key.encode('utf-8')
00204         # The blocks used by the associated value are lost.
00205         del self._index[key]
00206         # XXX It's unclear why we do a _commit() here (the code always
00207         # XXX has, so I'm not changing it).  __setitem__ doesn't try to
00208         # XXX keep the directory file in synch.  Why should we?  Or
00209         # XXX why shouldn't __setitem__?
00210         self._commit()

Here is the call graph for this function:

def _abcoll.Mapping.__eq__ (   self,
  other 
) [inherited]

Definition at line 380 of file _abcoll.py.

00380 
00381     def __eq__(self, other):
00382         if not isinstance(other, Mapping):
00383             return NotImplemented
00384         return dict(self.items()) == dict(other.items())

Here is the call graph for this function:

Here is the caller graph for this function:

def dbm.dumb._Database.__getitem__ (   self,
  key 
)

Reimplemented from _abcoll.Mapping.

Definition at line 121 of file dumb.py.

00121 
00122     def __getitem__(self, key):
00123         if isinstance(key, str):
00124             key = key.encode('utf-8')
00125         pos, siz = self._index[key]     # may raise KeyError
00126         f = _io.open(self._datfile, 'rb')
00127         f.seek(pos)
00128         dat = f.read(siz)
00129         f.close()
00130         return dat

Here is the caller graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def _abcoll.Iterable.__iter__ (   self) [inherited]

Reimplemented in collections.UserDict, test.support.EnvironmentVarGuard, collections._ChainMap, _abcoll.Sequence, os._Environ, _abcoll.ItemsView, _abcoll.KeysView, shelve.Shelf, and _abcoll.Iterator.

Definition at line 69 of file _abcoll.py.

00069 
00070     def __iter__(self):
00071         while False:
00072             yield None

Reimplemented from _abcoll.Sized.

Definition at line 226 of file dumb.py.

00226 
00227     def __len__(self):
00228         return len(self._index)

def _abcoll.Mapping.__ne__ (   self,
  other 
) [inherited]

Definition at line 385 of file _abcoll.py.

00385 
00386     def __ne__(self, other):
00387         return not (self == other)
00388 

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def dbm.dumb._Database.__setitem__ (   self,
  key,
  val 
)

Reimplemented from _abcoll.MutableMapping.

Definition at line 167 of file dumb.py.

00167 
00168     def __setitem__(self, key, val):
00169         if isinstance(key, str):
00170             key = key.encode('utf-8')
00171         elif not isinstance(key, (bytes, bytearray)):
00172             raise TypeError("keys must be bytes or strings")
00173         if isinstance(val, str):
00174             val = val.encode('utf-8')
00175         elif not isinstance(val, (bytes, bytearray)):
00176             raise TypeError("values must be bytes or strings")
00177         if key not in self._index:
00178             self._addkey(key, self._addval(val))
00179         else:
00180             # See whether the new value is small enough to fit in the
00181             # (padded) space currently occupied by the old value.
00182             pos, siz = self._index[key]
00183             oldblocks = (siz + _BLOCKSIZE - 1) // _BLOCKSIZE
00184             newblocks = (len(val) + _BLOCKSIZE - 1) // _BLOCKSIZE
00185             if newblocks <= oldblocks:
00186                 self._index[key] = self._setval(pos, val)
00187             else:
00188                 # The new value doesn't fit in the (padded) space used
00189                 # by the old value.  The blocks used by the old value are
00190                 # forever lost.
00191                 self._index[key] = self._addval(val)
00192 
00193             # Note that _index may be out of synch with the directory
00194             # file now:  _setval() and _addval() don't update the directory
00195             # file.  This also means that the on-disk directory and data
00196             # files are in a mutually inconsistent state, and they'll
00197             # remain that way until _commit() is called.  Note that this
00198             # is a disaster (for the database) if the program crashes
00199             # (so that _commit() never gets called).

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def _abcoll.Iterable.__subclasshook__ (   cls,
  C 
) [inherited]

Reimplemented in _abcoll.Iterator.

Definition at line 74 of file _abcoll.py.

00074 
00075     def __subclasshook__(cls, C):
00076         if cls is Iterable:
00077             if any("__iter__" in B.__dict__ for B in C.__mro__):
00078                 return True
00079         return NotImplemented
00080 

Here is the call graph for this function:

def _abcoll.Sized.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 119 of file _abcoll.py.

00119 
00120     def __subclasshook__(cls, C):
00121         if cls is Sized:
00122             if any("__len__" in B.__dict__ for B in C.__mro__):
00123                 return True
00124         return NotImplemented
00125 

Here is the call graph for this function:

def _abcoll.Container.__subclasshook__ (   cls,
  C 
) [inherited]

Definition at line 133 of file _abcoll.py.

00133 
00134     def __subclasshook__(cls, C):
00135         if cls is Container:
00136             if any("__contains__" in B.__dict__ for B in C.__mro__):
00137                 return True
00138         return NotImplemented
00139 

Here is the call graph for this function:

def dbm.dumb._Database._addkey (   self,
  key,
  pos_and_siz_pair 
) [private]

Definition at line 160 of file dumb.py.

00160 
00161     def _addkey(self, key, pos_and_siz_pair):
00162         self._index[key] = pos_and_siz_pair
00163         f = _io.open(self._dirfile, 'a', encoding="Latin-1")
00164         self._chmod(self._dirfile)
00165         f.write("%r, %r\n" % (key.decode("Latin-1"), pos_and_siz_pair))
00166         f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def dbm.dumb._Database._addval (   self,
  val 
) [private]

Definition at line 135 of file dumb.py.

00135 
00136     def _addval(self, val):
00137         f = _io.open(self._datfile, 'rb+')
00138         f.seek(0, 2)
00139         pos = int(f.tell())
00140         npos = ((pos + _BLOCKSIZE - 1) // _BLOCKSIZE) * _BLOCKSIZE
00141         f.write(b'\0'*(npos-pos))
00142         pos = npos
00143         f.write(val)
00144         f.close()
00145         return (pos, len(val))

Here is the caller graph for this function:

def dbm.dumb._Database._chmod (   self,
  file 
) [private]

Definition at line 235 of file dumb.py.

00235 
00236     def _chmod(self, file):
00237         if hasattr(self._os, 'chmod'):
00238             self._os.chmod(file, self._mode)
00239 

Here is the caller graph for this function:

def dbm.dumb._Database._commit (   self) [private]

Definition at line 94 of file dumb.py.

00094 
00095     def _commit(self):
00096         # CAUTION:  It's vital that _commit() succeed, and _commit() can
00097         # be called from __del__().  Therefore we must never reference a
00098         # global in this routine.
00099         if self._index is None:
00100             return  # nothing to do
00101 
00102         try:
00103             self._os.unlink(self._bakfile)
00104         except self._os.error:
00105             pass
00106 
00107         try:
00108             self._os.rename(self._dirfile, self._bakfile)
00109         except self._os.error:
00110             pass
00111 
00112         f = self._io.open(self._dirfile, 'w', encoding="Latin-1")
00113         self._chmod(self._dirfile)
00114         for key, pos_and_siz_pair in self._index.items():
00115             # Use Latin-1 since it has no qualms with any value in any
00116             # position; UTF-8, though, does care sometimes.
00117             f.write("%r, %r\n" % (key.decode('Latin-1'), pos_and_siz_pair))
00118         f.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def dbm.dumb._Database._setval (   self,
  pos,
  val 
) [private]

Definition at line 150 of file dumb.py.

00150 
00151     def _setval(self, pos, val):
00152         f = _io.open(self._datfile, 'rb+')
00153         f.seek(pos)
00154         f.write(val)
00155         f.close()
00156         return (pos, len(val))

Here is the caller graph for this function:

def dbm.dumb._Database._update (   self) [private]

Definition at line 77 of file dumb.py.

00077 
00078     def _update(self):
00079         self._index = {}
00080         try:
00081             f = _io.open(self._dirfile, 'r', encoding="Latin-1")
00082         except IOError:
00083             pass
00084         else:
00085             for line in f:
00086                 line = line.rstrip()
00087                 key, pos_and_siz_pair = eval(line)
00088                 key = key.encode('Latin-1')
00089                 self._index[key] = pos_and_siz_pair
00090             f.close()

Here is the caller graph for this function:

def _abcoll.MutableMapping.clear (   self) [inherited]

Reimplemented in collections._ChainMap.

Definition at line 486 of file _abcoll.py.

00486 
00487     def clear(self):
00488         try:
00489             while True:
00490                 self.popitem()
00491         except KeyError:
00492             pass

Here is the call graph for this function:

Here is the caller graph for this function:

def dbm.dumb._Database.close (   self)

Definition at line 229 of file dumb.py.

00229 
00230     def close(self):
00231         self._commit()
00232         self._index = self._datfile = self._dirfile = self._bakfile = None

Here is the call graph for this function:

def _abcoll.Mapping.get (   self,
  key,
  default = None 
) [inherited]

Reimplemented in collections._ChainMap, weakref.WeakKeyDictionary, weakref.WeakValueDictionary, and shelve.Shelf.

Definition at line 357 of file _abcoll.py.

00357 
00358     def get(self, key, default=None):
00359         try:
00360             return self[key]
00361         except KeyError:
00362             return default

Here is the caller graph for this function:

def dbm.dumb._Database.items (   self)

Reimplemented from _abcoll.Mapping.

Definition at line 214 of file dumb.py.

00214 
00215     def items(self):
00216         return [(key, self[key]) for key in self._index.keys()]

Here is the caller graph for this function:

Definition at line 222 of file dumb.py.

00222 
00223     def iterkeys(self):
        return iter(self._index.keys())

Here is the caller graph for this function:

def dbm.dumb._Database.keys (   self)

Reimplemented from _abcoll.Mapping.

Definition at line 211 of file dumb.py.

00211 
00212     def keys(self):
00213         return list(self._index.keys())

Here is the caller graph for this function:

def _abcoll.MutableMapping.pop (   self,
  key,
  default = __marker 
) [inherited]

Reimplemented in collections._ChainMap, weakref.WeakKeyDictionary, and weakref.WeakValueDictionary.

Definition at line 466 of file _abcoll.py.

00466 
00467     def pop(self, key, default=__marker):
00468         try:
00469             value = self[key]
00470         except KeyError:
00471             if default is self.__marker:
00472                 raise
00473             return default
00474         else:
00475             del self[key]
00476             return value

Here is the caller graph for this function:

def _abcoll.MutableMapping.popitem (   self) [inherited]

Reimplemented in collections._ChainMap, weakref.WeakKeyDictionary, and weakref.WeakValueDictionary.

Definition at line 477 of file _abcoll.py.

00477 
00478     def popitem(self):
00479         try:
00480             key = next(iter(self))
00481         except StopIteration:
00482             raise KeyError
00483         value = self[key]
00484         del self[key]
00485         return key, value

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def _abcoll.MutableMapping.setdefault (   self,
  key,
  default = None 
) [inherited]

Reimplemented in os._Environ, weakref.WeakKeyDictionary, and weakref.WeakValueDictionary.

Definition at line 514 of file _abcoll.py.

00514 
00515     def setdefault(self, key, default=None):
00516         try:
00517             return self[key]
00518         except KeyError:
00519             self[key] = default
00520         return default
00521 
00522 MutableMapping.register(dict)
00523 

def _abcoll.MutableMapping.update (   args,
  kwds 
) [inherited]

Definition at line 493 of file _abcoll.py.

00493 
00494     def update(*args, **kwds):
00495         if len(args) > 2:
00496             raise TypeError("update() takes at most 2 positional "
00497                             "arguments ({} given)".format(len(args)))
00498         elif not args:
00499             raise TypeError("update() takes at least 1 argument (0 given)")
00500         self = args[0]
00501         other = args[1] if len(args) >= 2 else ()
00502 
00503         if isinstance(other, Mapping):
00504             for key in other:
00505                 self[key] = other[key]
00506         elif hasattr(other, "keys"):
00507             for key in other.keys():
00508                 self[key] = other[key]
00509         else:
00510             for key, value in other:
00511                 self[key] = value
00512         for key, value in kwds.items():
00513             self[key] = value

Here is the caller graph for this function:

def _abcoll.Mapping.values (   self) [inherited]

Reimplemented in weakref.WeakKeyDictionary, weakref.WeakValueDictionary, and test.test_cfgparser.SortedDict.

Definition at line 377 of file _abcoll.py.

00377 
00378     def values(self):
00379         return ValuesView(self)

Here is the caller graph for this function:


Member Data Documentation

dbm.dumb._Database.__del__ = close [static, private]

Definition at line 233 of file dumb.py.

Definition at line 224 of file dumb.py.

Definition at line 62 of file dumb.py.

Definition at line 61 of file dumb.py.

Definition at line 55 of file dumb.py.

Definition at line 65 of file dumb.py.

dbm.dumb._Database._io = _io [static, private]

Definition at line 45 of file dumb.py.

Definition at line 48 of file dumb.py.

dbm.dumb._Database._os = _os [static, private]

Definition at line 44 of file dumb.py.

Definition at line 119 of file dumb.py.


The documentation for this class was generated from the following file: