MCPcopy Create free account
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/dbm/dumb.py:48–72  ·  view source on GitHub ↗
(self, filebasename, mode, flag='c')

Source from the content-addressed store, hash-verified

46 _io = _io # for _commit()
47
48 def __init__(self, filebasename, mode, flag='c'):
49 filebasename = self._os.fsencode(filebasename)
50 self._mode = mode
51 self._readonly = (flag == 'r')
52
53 # The directory file is a text file. Each line looks like
54 # "%r, (%d, %d)\n" % (key, pos, siz)
55 # where key is the string key, pos is the offset into the dat
56 # file of the associated value's first byte, and siz is the number
57 # of bytes in the associated value.
58 self._dirfile = filebasename + b'.dir'
59
60 # The data file is a binary file pointed into by the directory
61 # file, and holds the values associated with keys. Each value
62 # begins at a _BLOCKSIZE-aligned byte offset, and is a raw
63 # binary 8-bit string value.
64 self._datfile = filebasename + b'.dat'
65 self._bakfile = filebasename + b'.bak'
66
67 # The index is an in-memory dict, mirroring the directory file.
68 self._index = None # maps keys to (pos, siz) pairs
69
70 # Handle the creation
71 self._create(flag)
72 self._update(flag)
73
74 def _create(self, flag):
75 if flag == 'n':

Callers

nothing calls this directly

Calls 3

_createMethod · 0.95
_updateMethod · 0.95
fsencodeMethod · 0.80

Tested by

no test coverage detected