From 4081ed75b5e1d0315925bd2fcefb728b315f4f4b Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Tue, 16 Mar 2010 16:09:42 +0100 Subject: [PATCH] implement notmuch dump and Messages.len() --HG-- extra : transplant_source : %03_%C7%99L%16%7E%A8%B1p%11%11%A0%E3h%A3%AB%B6%FB%86 --- cnotmuch/database.py | 7 +++++++ notmuch | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cnotmuch/database.py b/cnotmuch/database.py index 19460b33..8d6124cb 100644 --- a/cnotmuch/database.py +++ b/cnotmuch/database.py @@ -253,6 +253,13 @@ class Tags(object): nmlib.notmuch_tags_move_to_next(self._tags) return tag + def __str__(self): + """str() of Tags() is a space separated list of tags + + This iterates over the list of Tags and will therefore 'exhaust' Tags() + """ + return " ".join(self) + def __del__(self): """Close and free the notmuch tags""" if self._tags is not None: diff --git a/notmuch b/notmuch index 56f961b4..172464c1 100755 --- a/notmuch +++ b/notmuch @@ -135,9 +135,17 @@ if __name__ == '__main__': querystr = quote_query_line(sys.argv[2:]) logging.debug("search-term "+querystr) db = Database() - m = Query(db,querystr).search_messages() + q = Query(db,querystr) + #TODO: notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID); + m = q.search_messages() print("\n".join([t for t in m.collect_tags()])) + elif sys.argv[1] == 'dump': + db = Database() + msgs = Query(db,'').search_messages() + for msg in msgs: + print("%s (%s)" % (msg.get_message_id(), msg.get_tags())) + else: # unknown command print "Error: Unknown command '%s' (see \"notmuch help\")" % sys.argv[1] @@ -153,10 +161,6 @@ show [...] Show all messages matching the search terms. -count [...] - - Count messages matching the search terms. - reply [options...] [...] Construct a reply template for a set of messages.