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

Method get_message

Lib/mailbox.py:1079–1102  ·  view source on GitHub ↗

Return a Message representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1077 _sync_close(f)
1078
1079 def get_message(self, key):
1080 """Return a Message representation or raise a KeyError."""
1081 try:
1082 if self._locked:
1083 f = open(os.path.join(self._path, str(key)), 'rb+')
1084 else:
1085 f = open(os.path.join(self._path, str(key)), 'rb')
1086 except OSError as e:
1087 if e.errno == errno.ENOENT:
1088 raise KeyError('No message with key: %s' % key)
1089 else:
1090 raise
1091 with f:
1092 if self._locked:
1093 _lock_file(f)
1094 try:
1095 msg = MHMessage(f)
1096 finally:
1097 if self._locked:
1098 _unlock_file(f)
1099 for name, key_list in self.get_sequences().items():
1100 if key in key_list:
1101 msg.add_sequence(name)
1102 return msg
1103
1104 def get_bytes(self, key):
1105 """Return a bytes representation or raise a KeyError."""

Callers 4

test_get_messageMethod · 0.45
test_get_MMMethod · 0.45
test_set_MMMethod · 0.45
test_issue2625Method · 0.45

Calls 9

get_sequencesMethod · 0.95
add_sequenceMethod · 0.95
strFunction · 0.85
_lock_fileFunction · 0.85
MHMessageClass · 0.85
_unlock_fileFunction · 0.85
openFunction · 0.70
joinMethod · 0.45
itemsMethod · 0.45

Tested by 4

test_get_messageMethod · 0.36
test_get_MMMethod · 0.36
test_set_MMMethod · 0.36
test_issue2625Method · 0.36