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

Method set_sequences

Lib/mailbox.py:1252–1279  ·  view source on GitHub ↗

Set sequences using the given name-to-key-list dictionary.

(self, sequences)

Source from the content-addressed store, hash-verified

1250 return results
1251
1252 def set_sequences(self, sequences):
1253 """Set sequences using the given name-to-key-list dictionary."""
1254 f = self._open_mh_sequences_file(text=True)
1255 try:
1256 os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
1257 for name, keys in sequences.items():
1258 if len(keys) == 0:
1259 continue
1260 f.write(name + ':')
1261 prev = None
1262 completing = False
1263 for key in sorted(set(keys)):
1264 if key - 1 == prev:
1265 if not completing:
1266 completing = True
1267 f.write('-')
1268 elif completing:
1269 completing = False
1270 f.write('%s %s' % (prev, key))
1271 else:
1272 f.write(' %s' % key)
1273 prev = key
1274 if completing:
1275 f.write(str(prev) + '\n')
1276 else:
1277 f.write('\n')
1278 finally:
1279 _sync_close(f)
1280
1281 def pack(self):
1282 """Re-name messages to eliminate numbering gaps. Invalidates keys."""

Callers 4

packMethod · 0.95
_dump_sequencesMethod · 0.95
test_sequencesMethod · 0.45

Calls 8

setFunction · 0.85
strFunction · 0.85
_sync_closeFunction · 0.85
closeMethod · 0.45
openMethod · 0.45
itemsMethod · 0.45
writeMethod · 0.45

Tested by 2

test_sequencesMethod · 0.36