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

Method get_bytes

Lib/mailbox.py:1104–1123  ·  view source on GitHub ↗

Return a bytes representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1102 return msg
1103
1104 def get_bytes(self, key):
1105 """Return a bytes representation or raise a KeyError."""
1106 try:
1107 if self._locked:
1108 f = open(os.path.join(self._path, str(key)), 'rb+')
1109 else:
1110 f = open(os.path.join(self._path, str(key)), 'rb')
1111 except OSError as e:
1112 if e.errno == errno.ENOENT:
1113 raise KeyError('No message with key: %s' % key)
1114 else:
1115 raise
1116 with f:
1117 if self._locked:
1118 _lock_file(f)
1119 try:
1120 return f.read().replace(linesep, b'\n')
1121 finally:
1122 if self._locked:
1123 _unlock_file(f)
1124
1125 def get_file(self, key):
1126 """Return a file-like representation or raise a KeyError."""

Callers 7

test_add_8bit_bodyMethod · 0.45
test_add_binary_fileMethod · 0.45
test_get_bytesMethod · 0.45
test_get_bytes_fromMethod · 0.45

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 7

test_add_8bit_bodyMethod · 0.36
test_add_binary_fileMethod · 0.36
test_get_bytesMethod · 0.36
test_get_bytes_fromMethod · 0.36