Example #1
0
    def __init__(self, filename, flag):
        """Constructor for the ShelfDatabase class.

        Args:
            filename (str): The filename of the database file.
            flag (str): a flag indicating the mode for opening the database.
                Refer to the documentation for anydbm.open().
        """
        super(ShelfDatabase, self).__init__()
        self._lock = RLock()
        self._shelf = Shelf(anydbm.open(filename, flag))
Example #2
0
def open(filename, flag='c'):
    """Open a persistent dictionary for reading and writing.

    The filename parameter is the base filename for the underlying
    database.  As a side-effect, an extension may be added to the
    filename and more than one file may be created.  The optional flag
    parameter has the same interpretation as the flag parameter of
    dbm.open().
    """
    writeback = False

    from . import _dumbdbm_patched
    d = _dumbdbm_patched.open(filename, flag)
    return Shelf(ZlibMapping(d) if zlib is not None else d)