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

Method _install_message

Lib/mailbox.py:866–892  ·  view source on GitHub ↗

Format a message and blindly write to self._file.

(self, message)

Source from the content-addressed store, hash-verified

864 return _PartialFile(self._file, self._file.tell(), stop)
865
866 def _install_message(self, message):
867 """Format a message and blindly write to self._file."""
868 from_line = None
869 if isinstance(message, str):
870 message = self._string_to_bytes(message)
871 if isinstance(message, bytes) and message.startswith(b'From '):
872 newline = message.find(b'\n')
873 if newline != -1:
874 from_line = message[:newline]
875 message = message[newline + 1:]
876 else:
877 from_line = message
878 message = b''
879 elif isinstance(message, _mboxMMDFMessage):
880 author = message.get_from().encode('ascii')
881 from_line = b'From ' + author
882 elif isinstance(message, email.message.Message):
883 from_line = message.get_unixfrom() # May be None.
884 if from_line is not None:
885 from_line = from_line.encode('ascii')
886 if from_line is None:
887 from_line = b'From MAILER-DAEMON ' + time.asctime(time.gmtime()).encode()
888 start = self._file.tell()
889 self._file.write(from_line + linesep)
890 self._dump_message(message, self._file, self._mangle_from_)
891 stop = self._file.tell()
892 return (start, stop)
893
894
895class mbox(_mboxMMDF):

Callers

nothing calls this directly

Calls 10

isinstanceFunction · 0.85
_string_to_bytesMethod · 0.80
get_fromMethod · 0.80
get_unixfromMethod · 0.80
_dump_messageMethod · 0.80
startswithMethod · 0.45
findMethod · 0.45
encodeMethod · 0.45
tellMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected