python: wrap notmuch_query_count_threads as Query.count_threads

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
This commit is contained in:
Justus Winter 2012-02-18 01:32:21 +01:00
parent 4315ac015a
commit ff8f864245
2 changed files with 21 additions and 0 deletions

View file

@ -128,6 +128,8 @@ More information on specific topics can be found on the following pages:
.. automethod:: count_messages
.. automethod:: count_threads
:class:`Messages` -- A bunch of messages
----------------------------------------

View file

@ -182,6 +182,25 @@ class Query(object):
self._assert_query_is_initialized()
return Query._count_messages(self._query)
_count_threads = nmlib.notmuch_query_count_threads
_count_threads.argtypes = [NotmuchQueryP]
_count_threads.restype = c_uint
def count_threads(self):
'''
This function performs a search and returns the number of
unique thread IDs in the matching messages. This is the same
as number of threads matching a search.
Note that this is a significantly heavier operation than
meth:`Query.count_messages`.
:returns: the number of threads returned by this query
:rtype: int
'''
self._assert_query_is_initialized()
return Query._count_threads(self._query)
_destroy = nmlib.notmuch_query_destroy
_destroy.argtypes = [NotmuchQueryP]
_destroy.restype = None