[PATCH 4/4] python: update bindings for new count API
authorDavid Bremner <david@tethera.net>
Sat, 7 Mar 2015 08:43:17 +0000 (09:43 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:17 +0000 (14:48 -0700)
79/f8c86e1326ed0498c386ebe11d19e931288b2a [new file with mode: 0644]

diff --git a/79/f8c86e1326ed0498c386ebe11d19e931288b2a b/79/f8c86e1326ed0498c386ebe11d19e931288b2a
new file mode 100644 (file)
index 0000000..ea938df
--- /dev/null
@@ -0,0 +1,115 @@
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0D558431FC0\r
+       for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 00:45:15 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+       tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id tWZTYvvh6+nY for <notmuch@notmuchmail.org>;\r
+       Sat,  7 Mar 2015 00:45:11 -0800 (PST)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+       [87.98.215.224])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 8BD03431FC4\r
+       for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 00:45:11 -0800 (PST)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+       4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+       id 1YUALW-0002KF-G3; Sat, 07 Mar 2015 08:44:30 +0000\r
+Received: (nullmailer pid 20414 invoked by uid 1000); Sat, 07 Mar 2015\r
+       08:43:24 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/4] python: update bindings for new count API\r
+Date: Sat,  7 Mar 2015 09:43:17 +0100\r
+Message-Id: <1425717797-19990-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net>\r
+References: <1419971380-10307-6-git-send-email-david@tethera.net>\r
+       <1425717797-19990-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 07 Mar 2015 08:45:15 -0000\r
+\r
+Note that any mismatches are not detected until runtime (if at all)\r
+with the python bindings, so tests are crucial\r
+---\r
+ bindings/python/notmuch/query.py | 24 ++++++++++++++++--------\r
+ 1 file changed, 16 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py\r
+index 94773ac..378aa47 100644\r
+--- a/bindings/python/notmuch/query.py\r
++++ b/bindings/python/notmuch/query.py\r
+@@ -17,7 +17,7 @@ along with notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
+ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
+ """\r
\r
+-from ctypes import c_char_p, c_uint\r
++from ctypes import c_char_p, c_uint, POINTER, byref\r
+ from .globals import (\r
+     nmlib,\r
+     Enum,\r
+@@ -178,8 +178,8 @@ class Query(object):\r
+             raise NullPointerError\r
+         return Messages(msgs_p, self)\r
\r
+-    _count_messages = nmlib.notmuch_query_count_messages\r
+-    _count_messages.argtypes = [NotmuchQueryP]\r
++    _count_messages = nmlib.notmuch_query_count_messages_st\r
++    _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
+     _count_messages.restype = c_uint\r
\r
+     def count_messages(self):\r
+@@ -191,10 +191,14 @@ class Query(object):\r
+         :rtype:   int\r
+         '''\r
+         self._assert_query_is_initialized()\r
+-        return Query._count_messages(self._query)\r
+-\r
+-    _count_threads = nmlib.notmuch_query_count_threads\r
+-    _count_threads.argtypes = [NotmuchQueryP]\r
++        count = c_uint(0)\r
++        status = Query._count_messages(self._query, byref(count))\r
++        if status != 0:\r
++            raise NotmuchError(status)\r
++        return count.value\r
++\r
++    _count_threads = nmlib.notmuch_query_count_threads_st\r
++    _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
+     _count_threads.restype = c_uint\r
\r
+     def count_threads(self):\r
+@@ -210,7 +214,11 @@ class Query(object):\r
+         :rtype:   int\r
+         '''\r
+         self._assert_query_is_initialized()\r
+-        return Query._count_threads(self._query)\r
++        count = c_uint(0)\r
++        status = Query._count_threads(self._query, byref(count))\r
++        if status != 0:\r
++            raise NotmuchError(status)\r
++        return count.value\r
\r
+     _destroy = nmlib.notmuch_query_destroy\r
+     _destroy.argtypes = [NotmuchQueryP]\r
+-- \r
+2.1.4\r
+\r