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

Method get_bytes

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

Return a bytes representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1046 return msg
1047
1048 def get_bytes(self, key):
1049 """Return a bytes representation or raise a KeyError."""
1050 try:
1051 if self._locked:
1052 f = open(os.path.join(self._path, str(key)), 'rb+')
1053 else:
1054 f = open(os.path.join(self._path, str(key)), 'rb')
1055 except OSError as e:
1056 if e.errno == errno.ENOENT:
1057 raise KeyError('No message with key: %s' % key)
1058 else:
1059 raise
1060 with f:
1061 if self._locked:
1062 _lock_file(f)
1063 try:
1064 return f.read().replace(linesep, b'\n')
1065 finally:
1066 if self._locked:
1067 _unlock_file(f)
1068
1069 def get_file(self, key):
1070 """Return a file-like representation or raise a KeyError."""

Callers

nothing calls this directly

Calls 7

strFunction · 0.85
_lock_fileFunction · 0.85
_unlock_fileFunction · 0.85
openFunction · 0.70
joinMethod · 0.45
replaceMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected