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

Method _append_message

Lib/mailbox.py:812–831  ·  view source on GitHub ↗

Append message to mailbox and return (start, stop) offsets.

(self, message)

Source from the content-addressed store, hash-verified

810 raise KeyError('No message with key: %s' % key) from None
811
812 def _append_message(self, message):
813 """Append message to mailbox and return (start, stop) offsets."""
814 self._file.seek(0, 2)
815 before = self._file.tell()
816 if len(self._toc) == 0 and not self._pending:
817 # This is the first message, and the _pre_mailbox_hook
818 # hasn't yet been called. If self._pending is True,
819 # messages have been removed, so _pre_mailbox_hook must
820 # have been called already.
821 self._pre_mailbox_hook(self._file)
822 try:
823 self._pre_message_hook(self._file)
824 offsets = self._install_message(message)
825 self._post_message_hook(self._file)
826 except BaseException:
827 self._file.truncate(before)
828 raise
829 self._file.flush()
830 self._file_length = self._file.tell() # Record current length of mailbox
831 return offsets
832
833
834

Callers 2

addMethod · 0.95
__setitem__Method · 0.95

Calls 8

_pre_mailbox_hookMethod · 0.95
_pre_message_hookMethod · 0.95
_post_message_hookMethod · 0.95
seekMethod · 0.45
tellMethod · 0.45
_install_messageMethod · 0.45
truncateMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected