MCPcopy Index your code
hub / github.com/python/cpython / _addval

Method _addval

Lib/dbm/dumb.py:158–166  ·  view source on GitHub ↗
(self, val)

Source from the content-addressed store, hash-verified

156 # to get to an aligned offset. Return pair
157 # (starting offset of val, len(val))
158 def _addval(self, val):
159 with _io.open(self._datfile, 'rb+') as f:
160 f.seek(0, 2)
161 pos = int(f.tell())
162 npos = ((pos + _BLOCKSIZE - 1) // _BLOCKSIZE) * _BLOCKSIZE
163 f.write(b'\0'*(npos-pos))
164 pos = npos
165 f.write(val)
166 return (pos, len(val))
167
168 # Write val to the data file, starting at offset pos. The caller
169 # is responsible for ensuring that there's enough room starting at

Callers 1

__setitem__Method · 0.95

Calls 4

openMethod · 0.45
seekMethod · 0.45
tellMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected