From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [Patch v4 6/9] python: update bindings for new count API
Date: Sun, 27 Sep 2015 12:32:00 -0300 [thread overview]
Message-ID: <1443367923-11867-7-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1443367923-11867-1-git-send-email-david@tethera.net>
Note that any mismatches are not detected until runtime (if at all)
with the python bindings, so tests are crucial
---
bindings/python/notmuch/query.py | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py
index 94773ac..378aa47 100644
--- a/bindings/python/notmuch/query.py
+++ b/bindings/python/notmuch/query.py
@@ -17,7 +17,7 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>.
Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
"""
-from ctypes import c_char_p, c_uint
+from ctypes import c_char_p, c_uint, POINTER, byref
from .globals import (
nmlib,
Enum,
@@ -178,8 +178,8 @@ class Query(object):
raise NullPointerError
return Messages(msgs_p, self)
- _count_messages = nmlib.notmuch_query_count_messages
- _count_messages.argtypes = [NotmuchQueryP]
+ _count_messages = nmlib.notmuch_query_count_messages_st
+ _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]
_count_messages.restype = c_uint
def count_messages(self):
@@ -191,10 +191,14 @@ class Query(object):
:rtype: int
'''
self._assert_query_is_initialized()
- return Query._count_messages(self._query)
-
- _count_threads = nmlib.notmuch_query_count_threads
- _count_threads.argtypes = [NotmuchQueryP]
+ count = c_uint(0)
+ status = Query._count_messages(self._query, byref(count))
+ if status != 0:
+ raise NotmuchError(status)
+ return count.value
+
+ _count_threads = nmlib.notmuch_query_count_threads_st
+ _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)]
_count_threads.restype = c_uint
def count_threads(self):
@@ -210,7 +214,11 @@ class Query(object):
:rtype: int
'''
self._assert_query_is_initialized()
- return Query._count_threads(self._query)
+ count = c_uint(0)
+ status = Query._count_threads(self._query, byref(count))
+ if status != 0:
+ raise NotmuchError(status)
+ return count.value
_destroy = nmlib.notmuch_query_destroy
_destroy.argtypes = [NotmuchQueryP]
--
2.5.3
next prev parent reply other threads:[~2015-09-27 15:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-27 15:31 v4 of count patches, plus convert remaining deprecated APIs David Bremner
2015-09-27 15:31 ` [Patch v4 1/9] lib: move query variable to function scope David Bremner
2015-09-27 15:31 ` [Patch v4 2/9] cli/count: simplify and document return value of print_count David Bremner
2015-09-27 15:31 ` [Patch v4 3/9] lib: add versions of n_q_count_{message, threads} with status return David Bremner
2015-10-05 18:22 ` Jani Nikula
2015-09-27 15:31 ` [Patch v4 4/9] cli: update to use new count API David Bremner
2015-10-05 18:25 ` Jani Nikula
2015-09-27 15:31 ` [Patch v4 5/9] ruby: " David Bremner
2015-09-27 15:32 ` David Bremner [this message]
2015-09-27 15:32 ` [Patch v4 7/9] lib: migrate notmuch_database_upgrade to new query_search API David Bremner
2015-10-05 18:27 ` Jani Nikula
2015-09-27 15:32 ` [Patch v4 8/9] lib: migrate thread.cc " David Bremner
2015-10-05 18:27 ` Jani Nikula
2015-09-27 15:32 ` [Patch v4 9/9] ruby: use " David Bremner
2015-10-05 23:30 ` v4 of count patches, plus convert remaining deprecated APIs David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443367923-11867-7-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).