Beispiel #1
0
 def maildir_msg(self) -> MaildirMessage:
     flag_str = self.maildir_flags.to_maildir(self.permanent_flags)
     msg_bytes = bytes(self.get_body(binary=True))
     maildir_msg = MaildirMessage(msg_bytes)
     maildir_msg.set_flags(flag_str)
     maildir_msg.set_subdir('new' if self.recent else 'cur')
     if self.internal_date is not None:
         maildir_msg.set_date(self.internal_date.timestamp())
     return maildir_msg
Beispiel #2
0
 def to_maildir(cls, prepared_msg: PreparedMessage, recent: bool,
                maildir_flags: MaildirFlags) -> MaildirMessage:
     flag_str = maildir_flags.to_maildir(prepared_msg.flag_set)
     when = prepared_msg.when or datetime.now()
     literal: bytes = prepared_msg.ref
     maildir_msg = MaildirMessage(literal)
     maildir_msg.set_flags(flag_str)
     maildir_msg.set_subdir('new' if recent else 'cur')
     maildir_msg.set_date(when.timestamp())
     return maildir_msg
Beispiel #3
0
    def get_message_metadata(self, key: str) -> MaildirMessage:
        """Like :meth:`~mailbox.Maildir.get_message` but the message contents
        are not read from disk.

        """
        msg = MaildirMessage()
        subpath = self._lookup(key)
        subdir, name = os.path.split(subpath)
        msg.set_subdir(subdir)
        if self.colon in name:
            msg.set_info(name.rsplit(self.colon, 1)[-1])
        msg.set_date(os.path.getmtime(os.path.join(self._path, subpath)))
        return msg
Beispiel #4
0
    def get_message_metadata(self, key: str) -> MaildirMessage:
        """Like :meth:`~mailbox.Maildir.get_message` but the message contents
        are not read from disk.

        """
        msg = MaildirMessage()
        subpath = self._lookup(key)
        subdir, name = os.path.split(subpath)
        msg.set_subdir(subdir)
        if self.colon in name:
            msg.set_info(name.rsplit(self.colon, 1)[-1])
        msg.set_date(os.path.getmtime(os.path.join(self._path, subpath)))
        return msg