我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用email.message_from_binary_file()。
def __init__(self, message=None): """Initialize a Message instance.""" if isinstance(message, email.message.Message): self._become_message(copy.deepcopy(message)) if isinstance(message, Message): message._explain_to(self) elif isinstance(message, bytes): self._become_message(email.message_from_bytes(message)) elif isinstance(message, str): self._become_message(email.message_from_string(message)) elif isinstance(message, io.TextIOWrapper): self._become_message(email.message_from_file(message)) elif hasattr(message, "read"): self._become_message(email.message_from_binary_file(message)) elif message is None: email.message.Message.__init__(self) else: raise TypeError('Invalid message type: %s' % type(message))
def seekable(self): return self.__seekable # Python 2 only has email.message_from_file(), but it behaves like Python 3's # email.message_from_binary_file().
def message_from_file(fp): msg = message_from_binary_file(fp,MimeMessage) for part in msg.walk(): part.modified = False assert not msg.ismodified() return msg