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

Method get_sequences

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

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

(self)

Source from the content-addressed store, hash-verified

1145 os.rmdir(path)
1146
1147 def get_sequences(self):
1148 """Return a name-to-key-list dictionary to define each sequence."""
1149 results = {}
1150 with open(os.path.join(self._path, '.mh_sequences'), 'r', encoding='ASCII') as f:
1151 all_keys = set(self.keys())
1152 for line in f:
1153 try:
1154 name, contents = line.split(':')
1155 keys = set()
1156 for spec in contents.split():
1157 if spec.isdigit():
1158 keys.add(int(spec))
1159 else:
1160 start, stop = (int(x) for x in spec.split('-'))
1161 keys.update(range(start, stop + 1))
1162 results[name] = [key for key in sorted(keys) \
1163 if key in all_keys]
1164 if len(results[name]) == 0:
1165 del results[name]
1166 except ValueError:
1167 raise FormatError('Invalid sequence specification: %s' %
1168 line.rstrip())
1169 return results
1170
1171 def set_sequences(self, sequences):
1172 """Set sequences using the given name-to-key-list dictionary."""

Callers 3

get_messageMethod · 0.95
packMethod · 0.95
_dump_sequencesMethod · 0.95

Calls 11

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

Tested by

no test coverage detected