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

Method set_sequences

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

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

(self, sequences)

Source from the content-addressed store, hash-verified

1169 return results
1170
1171 def set_sequences(self, sequences):
1172 """Set sequences using the given name-to-key-list dictionary."""
1173 f = open(os.path.join(self._path, '.mh_sequences'), 'r+', encoding='ASCII')
1174 try:
1175 os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
1176 for name, keys in sequences.items():
1177 if len(keys) == 0:
1178 continue
1179 f.write(name + ':')
1180 prev = None
1181 completing = False
1182 for key in sorted(set(keys)):
1183 if key - 1 == prev:
1184 if not completing:
1185 completing = True
1186 f.write('-')
1187 elif completing:
1188 completing = False
1189 f.write('%s %s' % (prev, key))
1190 else:
1191 f.write(' %s' % key)
1192 prev = key
1193 if completing:
1194 f.write(str(prev) + '\n')
1195 else:
1196 f.write('\n')
1197 finally:
1198 _sync_close(f)
1199
1200 def pack(self):
1201 """Re-name messages to eliminate numbering gaps. Invalidates keys."""

Callers 2

packMethod · 0.95
_dump_sequencesMethod · 0.95

Calls 10

sortedFunction · 0.85
strFunction · 0.85
_sync_closeFunction · 0.85
openFunction · 0.70
setFunction · 0.50
joinMethod · 0.45
closeMethod · 0.45
openMethod · 0.45
itemsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected