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

Method get_message

Lib/mailbox.py:1352–1378  ·  view source on GitHub ↗

Return a Message representation or raise a KeyError.

(self, key)

Source from the content-addressed store, hash-verified

1350 self._labels[key] = message.get_labels()
1351
1352 def get_message(self, key):
1353 """Return a Message representation or raise a KeyError."""
1354 start, stop = self._lookup(key)
1355 self._file.seek(start)
1356 self._file.readline() # Skip b'1,' line specifying labels.
1357 original_headers = io.BytesIO()
1358 while True:
1359 line = self._file.readline()
1360 if line == b'*** EOOH ***' + linesep or not line:
1361 break
1362 original_headers.write(line.replace(linesep, b'\n'))
1363 visible_headers = io.BytesIO()
1364 while True:
1365 line = self._file.readline()
1366 if line == linesep or not line:
1367 break
1368 visible_headers.write(line.replace(linesep, b'\n'))
1369 # Read up to the stop, or to the end
1370 n = stop - self._file.tell()
1371 assert n >= 0
1372 body = self._file.read(n)
1373 body = body.replace(linesep, b'\n')
1374 msg = BabylMessage(original_headers.getvalue() + body)
1375 msg.set_visible(visible_headers.getvalue())
1376 if key in self._labels:
1377 msg.set_labels(self._labels[key])
1378 return msg
1379
1380 def get_bytes(self, key):
1381 """Return a string representation or raise a KeyError."""

Callers

nothing calls this directly

Calls 11

writeMethod · 0.95
getvalueMethod · 0.95
set_visibleMethod · 0.95
set_labelsMethod · 0.95
BabylMessageClass · 0.85
_lookupMethod · 0.45
seekMethod · 0.45
readlineMethod · 0.45
replaceMethod · 0.45
tellMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected