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

Method get_sequences

Lib/mailbox.py:1224–1250  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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

setFunction · 0.85
FormatErrorClass · 0.85
isdigitMethod · 0.80
openFunction · 0.70
joinMethod · 0.45
keysMethod · 0.45
splitMethod · 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