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

Method get_message

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

Return a Message representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1021 _sync_close(f)
1022
1023 def get_message(self, key):
1024 """Return a Message representation or raise a KeyError."""
1025 try:
1026 if self._locked:
1027 f = open(os.path.join(self._path, str(key)), 'rb+')
1028 else:
1029 f = open(os.path.join(self._path, str(key)), 'rb')
1030 except OSError as e:
1031 if e.errno == errno.ENOENT:
1032 raise KeyError('No message with key: %s' % key)
1033 else:
1034 raise
1035 with f:
1036 if self._locked:
1037 _lock_file(f)
1038 try:
1039 msg = MHMessage(f)
1040 finally:
1041 if self._locked:
1042 _unlock_file(f)
1043 for name, key_list in self.get_sequences().items():
1044 if key in key_list:
1045 msg.add_sequence(name)
1046 return msg
1047
1048 def get_bytes(self, key):
1049 """Return a bytes representation or raise a KeyError."""

Callers

nothing calls this directly

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

no test coverage detected