MCPcopy Index your code
hub / github.com/RustPython/RustPython / pack

Method pack

Lib/mailbox.py:1274–1298  ·  view source on GitHub ↗

Re-name messages to eliminate numbering gaps. Invalidates keys.

(self)

Source from the content-addressed store, hash-verified

1272 _sync_close(f)
1273
1274 def pack(self):
1275 """Re-name messages to eliminate numbering gaps. Invalidates keys."""
1276 sequences = self.get_sequences()
1277 prev = 0
1278 changes = []
1279 for key in self.iterkeys():
1280 if key - 1 != prev:
1281 changes.append((key, prev + 1))
1282 try:
1283 os.link(os.path.join(self._path, str(key)),
1284 os.path.join(self._path, str(prev + 1)))
1285 except (AttributeError, PermissionError):
1286 os.rename(os.path.join(self._path, str(key)),
1287 os.path.join(self._path, str(prev + 1)))
1288 else:
1289 os.unlink(os.path.join(self._path, str(key)))
1290 prev += 1
1291 self._next_key = prev + 1
1292 if len(changes) == 0:
1293 return
1294 for name, key_list in sequences.items():
1295 for old, new in changes:
1296 if old in key_list:
1297 key_list[key_list.index(old)] = new
1298 self.set_sequences(sequences)
1299
1300 def _dump_sequences(self, message, key):
1301 """Inspect a new MHMessage and update sequences appropriately."""

Callers 12

compile_fileFunction · 0.45
writeMethod · 0.45
_write_sizeMethod · 0.45
_write_objectMethod · 0.45
_write_headerMethod · 0.45
_patchheaderMethod · 0.45
_init_write_gzMethod · 0.45
closeMethod · 0.45
_create_headerMethod · 0.45
write32uFunction · 0.45
compressFunction · 0.45
stdlib_struct.pyFile · 0.45

Calls 11

get_sequencesMethod · 0.95
iterkeysMethod · 0.95
set_sequencesMethod · 0.95
strFunction · 0.85
lenFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45
renameMethod · 0.45
unlinkMethod · 0.45
itemsMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected