]> git.notmuchmail.org Git - notmuch/blobdiff - cnotmuch/message.py
rename show_messages to print_messages and fix up the arg parsing for notmuch show...
[notmuch] / cnotmuch / message.py
index 29a914dd70103abae7f28da7f63e4f36e3c8b0ca..7274c6da62de68d3854d93199afd63aadd9481b0 100644 (file)
@@ -172,14 +172,19 @@ class Messages(object):
         self._msgs = None
         return i
 
-
-
     def __del__(self):
         """Close and free the notmuch Messages"""
         if self._msgs is not None:
             nmlib.notmuch_messages_destroy (self._msgs)
 
-    def show_messages(self, format, indent=0, entire_thread=True):
+    def print_messages(self, format, indent=0, entire_thread=False):
+        """Outputs messages as needed for 'notmuch show' to sys.stdout
+
+        :param format: A string of either 'text' or 'json'.
+        :param indent: A number indicating the reply depth of these messages.
+        :param entire_thread: A bool, indicating whether we want to output 
+                       whole threads or only the matching messages.
+        """
         if format.lower() == "text":
             set_start = ""
             set_end = ""
@@ -195,6 +200,7 @@ class Messages(object):
 
         sys.stdout.write(set_start)
 
+        # iterate through all toplevel messages in this thread
         for msg in self:
             # if not msg:
             #     break 
@@ -221,8 +227,7 @@ class Messages(object):
             #     break
             if not replies is None:
                 sys.stdout.write(set_sep)
-                replies.show_messages(format, next_indent, entire_thread)
-
+                replies.print_messages(format, next_indent, entire_thread)
 
             sys.stdout.write(set_end)
         sys.stdout.write(set_end)
@@ -627,7 +632,7 @@ class Message(object):
 
     def is_match(self):
         """(Not implemented)"""
-        return self.get_flag(self.FLAG.MATCH)
+        return self.get_flag(Message.FLAG.MATCH)
 
     def __str__(self):
         """A message() is represented by a 1-line summary"""
@@ -716,18 +721,16 @@ class Message(object):
         easy to change to a new format when the format changes."""
 
         format = self.format_message_internal()
-        output = "\n\fmessage{ id:%s depth:%d filename:%s" % (format["id"],
-                                                              indent,
-                                                              format["filename"])
+        output = "\n\fmessage{ id:%s depth:%d match:%d filename:%s" \
+                 % (format['id'], indent, format['match'], format['filename'])
         output += "\n\fheader{"
 
-        #Todo: this date is supposed to be cleaned up, as in the index.
+        #Todo: this date is supposed to be prettified, as in the index.
         output += "\n%s (%s) (" % (format["headers"]["from"],
                                    format["headers"]["date"])
         output += ", ".join(format["tags"])
         output += ")\n"
 
-
         output += "\nSubject: %s" % format["headers"]["subject"]
         output += "\nFrom: %s" % format["headers"]["from"]
         output += "\nTo: %s" % format["headers"]["to"]
@@ -764,7 +767,6 @@ class Message(object):
 
         return output
 
-
     def __del__(self):
         """Close and free the notmuch Message"""
         if self._msg is not None: