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

Method get_sequences

Lib/mailbox.py:1217–1243  ·  view source on GitHub ↗

Return a name-to-key-list dictionary to define each sequence.

(self)

Source from the content-addressed store, hash-verified

1215 os.rmdir(path)
1216
1217 def get_sequences(self):
1218 """Return a name-to-key-list dictionary to define each sequence."""
1219 results = {}
1220 try:
1221 f = open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII')
1222 except FileNotFoundError:
1223 return results
1224 with f:
1225 all_keys = set(self.keys())
1226 for line in f:
1227 try:
1228 name, contents = line.split(':')
1229 keys = set()
1230 for spec in contents.split():
1231 if spec.isdigit():
1232 keys.add(int(spec))
1233 else:
1234 start, stop = (int(x) for x in spec.split('-'))
1235 keys.update(range(start, stop + 1))
1236 results[name] = [key for key in sorted(keys) \
1237 if key in all_keys]
1238 if len(results[name]) == 0:
1239 del results[name]
1240 except ValueError:
1241 raise FormatError('Invalid sequence specification: %s' %
1242 line.rstrip())
1243 return results
1244
1245 def set_sequences(self, sequences):
1246 """Set sequences using the given name-to-key-list dictionary."""

Callers 10

get_messageMethod · 0.95
packMethod · 0.95
_dump_sequencesMethod · 0.95
test_sequencesMethod · 0.45
test_packMethod · 0.45
test_maildir_to_mhMethod · 0.45
test_mboxmmdf_to_mhMethod · 0.45
test_mh_to_mhMethod · 0.45
test_babyl_to_mhMethod · 0.45

Calls 12

setFunction · 0.85
sortedFunction · 0.85
lenFunction · 0.85
FormatErrorClass · 0.85
openFunction · 0.70
joinMethod · 0.45
keysMethod · 0.45
splitMethod · 0.45
isdigitMethod · 0.45
addMethod · 0.45
updateMethod · 0.45
rstripMethod · 0.45

Tested by 7

test_sequencesMethod · 0.36
test_packMethod · 0.36
test_maildir_to_mhMethod · 0.36
test_mboxmmdf_to_mhMethod · 0.36
test_mh_to_mhMethod · 0.36
test_babyl_to_mhMethod · 0.36