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

Method set_sequences

Lib/mailbox.py:1245–1272  ·  view source on GitHub ↗

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

(self, sequences)

Source from the content-addressed store, hash-verified

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

Callers 4

packMethod · 0.95
_dump_sequencesMethod · 0.95
test_sequencesMethod · 0.45

Calls 10

lenFunction · 0.85
sortedFunction · 0.85
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