Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 79 / f8c86e1326ed0498c386ebe11d19e931288b2a
1 Return-Path: <bremner@tesseract.cs.unb.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 0D558431FC0\r
6         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 00:45:15 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id tWZTYvvh6+nY for <notmuch@notmuchmail.org>;\r
16         Sat,  7 Mar 2015 00:45:11 -0800 (PST)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224])\r
19         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 8BD03431FC4\r
22         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 00:45:11 -0800 (PST)\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
24         4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
25         id 1YUALW-0002KF-G3; Sat, 07 Mar 2015 08:44:30 +0000\r
26 Received: (nullmailer pid 20414 invoked by uid 1000); Sat, 07 Mar 2015\r
27         08:43:24 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH 4/4] python: update bindings for new count API\r
31 Date: Sat,  7 Mar 2015 09:43:17 +0100\r
32 Message-Id: <1425717797-19990-5-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.4\r
34 In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net>\r
35 References: <1419971380-10307-6-git-send-email-david@tethera.net>\r
36         <1425717797-19990-1-git-send-email-david@tethera.net>\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Sat, 07 Mar 2015 08:45:15 -0000\r
50 \r
51 Note that any mismatches are not detected until runtime (if at all)\r
52 with the python bindings, so tests are crucial\r
53 ---\r
54  bindings/python/notmuch/query.py | 24 ++++++++++++++++--------\r
55  1 file changed, 16 insertions(+), 8 deletions(-)\r
56 \r
57 diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py\r
58 index 94773ac..378aa47 100644\r
59 --- a/bindings/python/notmuch/query.py\r
60 +++ b/bindings/python/notmuch/query.py\r
61 @@ -17,7 +17,7 @@ along with notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
62  Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>\r
63  """\r
64  \r
65 -from ctypes import c_char_p, c_uint\r
66 +from ctypes import c_char_p, c_uint, POINTER, byref\r
67  from .globals import (\r
68      nmlib,\r
69      Enum,\r
70 @@ -178,8 +178,8 @@ class Query(object):\r
71              raise NullPointerError\r
72          return Messages(msgs_p, self)\r
73  \r
74 -    _count_messages = nmlib.notmuch_query_count_messages\r
75 -    _count_messages.argtypes = [NotmuchQueryP]\r
76 +    _count_messages = nmlib.notmuch_query_count_messages_st\r
77 +    _count_messages.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
78      _count_messages.restype = c_uint\r
79  \r
80      def count_messages(self):\r
81 @@ -191,10 +191,14 @@ class Query(object):\r
82          :rtype:   int\r
83          '''\r
84          self._assert_query_is_initialized()\r
85 -        return Query._count_messages(self._query)\r
86 -\r
87 -    _count_threads = nmlib.notmuch_query_count_threads\r
88 -    _count_threads.argtypes = [NotmuchQueryP]\r
89 +        count = c_uint(0)\r
90 +        status = Query._count_messages(self._query, byref(count))\r
91 +        if status != 0:\r
92 +            raise NotmuchError(status)\r
93 +        return count.value\r
94 +\r
95 +    _count_threads = nmlib.notmuch_query_count_threads_st\r
96 +    _count_threads.argtypes = [NotmuchQueryP, POINTER(c_uint)]\r
97      _count_threads.restype = c_uint\r
98  \r
99      def count_threads(self):\r
100 @@ -210,7 +214,11 @@ class Query(object):\r
101          :rtype:   int\r
102          '''\r
103          self._assert_query_is_initialized()\r
104 -        return Query._count_threads(self._query)\r
105 +        count = c_uint(0)\r
106 +        status = Query._count_threads(self._query, byref(count))\r
107 +        if status != 0:\r
108 +            raise NotmuchError(status)\r
109 +        return count.value\r
110  \r
111      _destroy = nmlib.notmuch_query_destroy\r
112      _destroy.argtypes = [NotmuchQueryP]\r
113 -- \r
114 2.1.4\r
115 \r