MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / pack

Method pack

tools/python-3.11.9-amd64/Lib/mailbox.py:1200–1224  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

1198 _sync_close(f)
1199
1200 def pack(self):
1201 """Re-name messages to eliminate numbering gaps. Invalidates keys."""
1202 sequences = self.get_sequences()
1203 prev = 0
1204 changes = []
1205 for key in self.iterkeys():
1206 if key - 1 != prev:
1207 changes.append((key, prev + 1))
1208 try:
1209 os.link(os.path.join(self._path, str(key)),
1210 os.path.join(self._path, str(prev + 1)))
1211 except (AttributeError, PermissionError):
1212 os.rename(os.path.join(self._path, str(key)),
1213 os.path.join(self._path, str(prev + 1)))
1214 else:
1215 os.unlink(os.path.join(self._path, str(key)))
1216 prev += 1
1217 self._next_key = prev + 1
1218 if len(changes) == 0:
1219 return
1220 for name, key_list in sequences.items():
1221 for old, new in changes:
1222 if old in key_list:
1223 key_list[key_list.index(old)] = new
1224 self.set_sequences(sequences)
1225
1226 def _dump_sequences(self, message, key):
1227 """Inspect a new MHMessage and update sequences appropriately."""

Callers 15

compile_fileFunction · 0.45
writeMethod · 0.45
_write_sizeMethod · 0.45
_write_objectMethod · 0.45
setupcanvasMethod · 0.45
_write_headerMethod · 0.45
_patchheaderMethod · 0.45
_init_write_gzMethod · 0.45
closeMethod · 0.45
_create_headerMethod · 0.45
_write_shortFunction · 0.45
_write_ushortFunction · 0.45

Calls 11

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

Tested by

no test coverage detected