From 95f259409ef48dbd31c3670a5e2fe288f05ba2a0 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Tue, 16 Mar 2010 16:20:47 +0100 Subject: [PATCH] implement Query.set_sort() and sort notmuch dump by message id --HG-- extra : transplant_source : 1%BC%F3%ED%3C%C7c%0EFh%06%B6L%7C%8E%8F%EF%A2%8E%A8 --- cnotmuch/database.py | 10 ++++++++++ notmuch | 11 ++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cnotmuch/database.py b/cnotmuch/database.py index 8d6124cb..09af0df9 100644 --- a/cnotmuch/database.py +++ b/cnotmuch/database.py @@ -185,6 +185,16 @@ class Query(object): NotmuchError(STATUS.NULL_POINTER) self._query = query_p + def set_sort(self, sort): + """notmuch_query_set_sort + + :param sort: one of Query.SORT_OLDEST_FIRST|SORT_NEWEST_FIRST|SORT_MESSAGE_ID + :returns: Nothing, but raises NotmuchError if query is not inited + """ + if self._query is None: + raise NotmuchError(STATUS.NOT_INITIALIZED) + + nmlib.notmuch_query_set_sort(self._query, sort) def search_messages(self): """notmuch_query_search_messages diff --git a/notmuch b/notmuch index 172464c1..478aed3a 100755 --- a/notmuch +++ b/notmuch @@ -135,15 +135,16 @@ if __name__ == '__main__': querystr = quote_query_line(sys.argv[2:]) logging.debug("search-term "+querystr) db = Database() - q = Query(db,querystr) - #TODO: notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID); - m = q.search_messages() + m = Query(db,querystr).search_messages() print("\n".join([t for t in m.collect_tags()])) elif sys.argv[1] == 'dump': + #TODO: implement "dump " db = Database() - msgs = Query(db,'').search_messages() - for msg in msgs: + q = Query(db,'') + q.set_sort(Query.SORT_MESSAGE_ID) + m = q.search_messages() + for msg in m: print("%s (%s)" % (msg.get_message_id(), msg.get_tags())) else: -- 2.26.2