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

Method _update

Lib/dbm/dumb.py:93–109  ·  view source on GitHub ↗
(self, flag)

Source from the content-addressed store, hash-verified

91
92 # Read directory file into the in-memory index dict.
93 def _update(self, flag):
94 self._modified = False
95 self._index = {}
96 try:
97 f = _io.open(self._dirfile, 'r', encoding="Latin-1")
98 except OSError:
99 if flag not in ('c', 'n'):
100 raise
101 with self._io.open(self._dirfile, 'w', encoding="Latin-1") as f:
102 self._chmod(self._dirfile)
103 else:
104 with f:
105 for line in f:
106 line = line.rstrip()
107 key, pos_and_siz_pair = _ast.literal_eval(line)
108 key = key.encode('Latin-1')
109 self._index[key] = pos_and_siz_pair
110
111 # Write the index dict to the directory file. The original directory
112 # file (if any) is renamed with a .bak extension first. If a .bak

Callers 1

__init__Method · 0.95

Calls 4

_chmodMethod · 0.95
openMethod · 0.45
rstripMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected