Class t.p.d.DirDBM:

Part of twisted.persisted.dirdbm View Source View In Hierarchy

Known subclasses: twisted.persisted.dirdbm.Shelf

A directory with a DBM interface.

This class presents a hash-like interface to a directory of small, flat files. It can only use strings as keys or values.
Method __init__
Method _encode Encode a key so it can be used as a filename.
Method _decode Decode a filename to get the key.
Method _readFile Read in the contents of a file.
Method _writeFile Write data to a file.
Method __len__
Method __setitem__ dirdbm[k] = v
Method __getitem__ dirdbm[k]
Method __delitem__ del dirdbm[foo]
Method keys
Method values
Method items
Method has_key
Method setdefault
Method get
Method __contains__ key in dirdbm
Method update Add all the key/value pairs in dict to this dirdbm. Any conflicting
Method copyTo Copy the contents of this dirdbm to the dirdbm at path.
Method clear Delete all key/value pairs in this dirdbm.
Method close Close this dbm: no-op, for dbm-style interface compliance.
Method getModificationTime Returns modification time of an entry.
def __init__(self, name): (source)
ParametersnameBase path to use for the directory storage. (type: str )
def _encode(self, k): (source)
Encode a key so it can be used as a filename.
def _decode(self, k): (source)
Decode a filename to get the key.
def _readFile(self, path): (source)

Read in the contents of a file.

Override in subclasses to e.g. provide transparently encrypted dirdbm.
def _writeFile(self, path, data): (source)

Write data to a file.

Override in subclasses to e.g. provide transparently encrypted dirdbm.
def __len__(self): (source)
ReturnsThe number of key/value pairs in this Shelf
def __setitem__(self, k, v): (source)
dirdbm[k] = v Create or modify a textfile in this directory
Parameterskkey to set (type: str )
vvalue to associate with k (type: str )
def __getitem__(self, k): (source)
dirdbm[k] Get the contents of a file in this directory as a string.
Parameterskkey to lookup (type: str )
ReturnsThe value associated with k
RaisesKeyErrorRaised when there is no such key
def __delitem__(self, k): (source)
del dirdbm[foo] Delete a file in this directory.
Parameterskkey to delete (type: str )
RaisesKeyErrorRaised when there is no such key
def keys(self): (source)
Returnsa list of filenames (keys).
def values(self): (source)
Returnsa list of file-contents (values).
def items(self): (source)
Returnsa list of 2-tuples containing key/value pairs.
def has_key(self, key): (source)
ParameterskeyThe key to test (type: str )
ReturnsA true value if this dirdbm has the specified key, a faluse value otherwise.
def setdefault(self, key, value): (source)
ParameterskeyThe key to lookup (type: str )
valueThe value to associate with key if key is not already associated with a value.
def get(self, key, default=None): (source)
ParameterskeyThe key to lookup (type: str )
defaultThe value to return if the given key does not exist
ReturnsThe value associated with key or default if not self.has_key(key)
def __contains__(self, key): (source)
key in dirdbm
ParameterskeyThe key to test (type: str )
ReturnsA true value if self.has_key(key), a false value otherwise.
def update(self, dict): (source)
Add all the key/value pairs in dict to this dirdbm. Any conflicting keys will be overwritten with the values from dict.
ParametersdictA mapping of key/value pairs to add to this dirdbm. (type: mapping )
def copyTo(self, path): (source)
Copy the contents of this dirdbm to the dirdbm at path.
ParameterspathThe path of the dirdbm to copy to. If a dirdbm exists at the destination path, it is cleared first. (type: str )
ReturnsThe dirdbm this dirdbm was copied to. (type: DirDBM )
def clear(self): (source)
Delete all key/value pairs in this dirdbm.
def close(self): (source)
Close this dbm: no-op, for dbm-style interface compliance.
def getModificationTime(self, key): (source)
Returns modification time of an entry.
ReturnsLast modification date (seconds since epoch) of entry key
RaisesKeyErrorRaised when there is no such key
API Documentation for twisted, generated by pydoctor.