(self, message)
return offsets
Append message to mailbox and return (start, stop) offsets.
Append message to mailbox and return (start, stop) offsets.
Append message to mailbox and return ( start stop ) offsets .
def _append_message(self, message):
        """Append message to mailbox and return (start, stop) offsets."""
        self._file.seek(0, 2)
        before = self._file.tell()
        if len(self._toc) == 0 and not self._pending:
            # This is the first message, and the _pre_mailbox_hook
            # hasn't yet been called. If self._pending is True,
            # messages have been removed, so _pre_mailbox_hook must
            # have been called already.
            self._pre_mailbox_hook(self._file)
        try:
            self._pre_message_hook(self._file)
            offsets = self._install_message(message)
            self._post_message_hook(self._file)
        except BaseException:
            self._file.truncate(before)
            raise
        self._file.flush()
        self._file_length = self._file.tell()  # Record current length of mailbox
        return offsets
def _append_message ( self , message ) : self . _file . seek ( 0 , 2 ) before = self . _file . tell ( ) if len ( self . _toc ) == 0 and not self . _pending : # This is the first message, and the _pre_mailbox_hook # hasn't yet been called. If self._pending is True, # messages have been removed, so _pre_mailbox_hook must # have been called already. self . _pre_mailbox_hook ( self . _file ) try : self . _pre_message_hook ( self . _file ) offsets = self . _install_message ( message ) self . _post_message_hook ( self . _file ) except BaseException : self . _file . truncate ( before ) raise self . _file . flush ( ) self . _file_length = self . _file . tell ( ) # Record current length of mailbox return offsets