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

Method __getitem__

Lib/dbm/dumb.py:144–152  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

142 raise error('DBM object has already been closed')
143
144 def __getitem__(self, key):
145 if isinstance(key, str):
146 key = key.encode('utf-8')
147 self._verify_open()
148 pos, siz = self._index[key] # may raise KeyError
149 with _io.open(self._datfile, 'rb') as f:
150 f.seek(pos)
151 dat = f.read(siz)
152 return dat
153
154 # Append val to the data file, starting at a _BLOCKSIZE-aligned
155 # offset. The data file is first padded with NUL bytes (if needed)

Callers

nothing calls this directly

Calls 5

_verify_openMethod · 0.95
encodeMethod · 0.45
openMethod · 0.45
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected