- def __str__(self):
- """A message() is represented by a 1-line summary"""
- msg = {}
- msg['from'] = self.get_header('from')
- msg['tags'] = str(self.get_tags())
- msg['date'] = date.fromtimestamp(self.get_date())
- replies = self.get_replies()
- msg['replies'] = len(replies) if replies is not None else -1
- return "%(from)s (%(date)s) (%(tags)s) (%(replies)d) replies" % (msg)
+ def tags_to_maildir_flags(self):
+ """Synchronize notmuch tags to file Maildir flags
+
+ 'D' if the message has the "draft" tag
+ 'F' if the message has the "flagged" tag
+ 'P' if the message has the "passed" tag
+ 'R' if the message has the "replied" tag
+ 'S' if the message does not have the "unread" tag
+
+ Any existing flags unmentioned in the list above will be
+ preserved in the renaming.
+
+ Also, if this filename is in a directory named "new", rename it
+ to be within the neighboring directory named "cur".
+
+ Do note that calling this method while a message is frozen might
+ not work yet, as the modified tags have not been committed yet
+ to the database.
+
+ :returns: a :class:`STATUS` value. In short, you want to see
+ notmuch.STATUS.SUCCESS here. See there for details."""
+ if self._msg is None:
+ raise NotmuchError(STATUS.NOT_INITIALIZED)
+ return Message._tags_to_maildir_flags(self._msg)
+
+ def maildir_flags_to_tags(self):
+ """Synchronize file Maildir flags to notmuch tags
+
+ Flag Action if present
+ ---- -----------------
+ 'D' Adds the "draft" tag to the message
+ 'F' Adds the "flagged" tag to the message
+ 'P' Adds the "passed" tag to the message
+ 'R' Adds the "replied" tag to the message
+ 'S' Removes the "unread" tag from the message
+
+ For each flag that is not present, the opposite action
+ (add/remove) is performed for the corresponding tags. If there
+ are multiple filenames associated with this message, the flag is
+ considered present if it appears in one or more filenames. (That
+ is, the flags from the multiple filenames are combined with the
+ logical OR operator.)
+
+ As a convenience, you can set the sync_maildir_flags parameter in
+ :meth:`Database.add_message` to implicitly call this.
+
+ :returns: a :class:`STATUS`. In short, you want to see
+ notmuch.STATUS.SUCCESS here. See there for details."""
+ if self._msg is None:
+ raise NotmuchError(STATUS.NOT_INITIALIZED)
+ return Message._tags_to_maildir_flags(self._msg)