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

Method get_message

Lib/mailbox.py:1086–1109  ·  view source on GitHub ↗

Return a Message representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1084 _sync_close(f)
1085
1086 def get_message(self, key):
1087 """Return a Message representation or raise a KeyError."""
1088 try:
1089 if self._locked:
1090 f = open(os.path.join(self._path, str(key)), 'rb+')
1091 else:
1092 f = open(os.path.join(self._path, str(key)), 'rb')
1093 except OSError as e:
1094 if e.errno == errno.ENOENT:
1095 raise KeyError('No message with key: %s' % key)
1096 else:
1097 raise
1098 with f:
1099 if self._locked:
1100 _lock_file(f)
1101 try:
1102 msg = MHMessage(f)
1103 finally:
1104 if self._locked:
1105 _unlock_file(f)
1106 for name, key_list in self.get_sequences().items():
1107 if key in key_list:
1108 msg.add_sequence(name)
1109 return msg
1110
1111 def get_bytes(self, key):
1112 """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