Re: Possible addtions to notmuch new ?
[notmuch-archives.git] / 62 / b0dc11019a33c69cbe22d1fb919ffa87a7eb6d
1 Return-Path: <teythoon@jade-hamburg.de>\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 A5F5441434B\r
6         for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 06:06:54 -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: 0.001\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
12         tests=[UNPARSEABLE_RELAY=0.001] 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 XCMf3xwDtIIl for <notmuch@notmuchmail.org>;\r
16         Sun,  8 Jan 2012 06:06:51 -0800 (PST)\r
17 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 2F35A414343\r
21         for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 06:06:51 -0800 (PST)\r
22 Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
23         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
24         (No client certificate requested)\r
25         by mail.cryptobitch.de (Postfix) with ESMTPSA id A3768513C80\r
26         for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 15:06:49 +0100 (CET)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id EA9DADF2A2; Sun,  8 Jan 2012 15:06:48 +0100 (CET)\r
29 Received: from thinkbox.jade-hamburg.de (unknown\r
30         [IPv6:fe80::216:d3ff:fe3e:5058%br0])\r
31         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
32         (No client certificate requested) (Authenticated sender: teythoon)\r
33         by mail.jade-hamburg.de (Postfix) with ESMTPSA id 7A5BBDF2A0;\r
34         Sun,  8 Jan 2012 15:06:47 +0100 (CET)\r
35 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
36         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
37         id 1RjtOY-0007wh-Ty; Sun, 08 Jan 2012 15:06:47 +0100\r
38 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH] py3k: the basestring and unicode types are removed in python\r
41  3\r
42 Date: Sun,  8 Jan 2012 15:06:29 +0100\r
43 Message-Id:\r
44  <1326031589-30506-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
45 X-Mailer: git-send-email 1.7.7.3\r
46 In-Reply-To: <20120108140444.26863.68188@thinkbox.jade-hamburg.de>\r
47 References: <20120108140444.26863.68188@thinkbox.jade-hamburg.de>\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Sun, 08 Jan 2012 14:06:54 -0000\r
61 \r
62 ---\r
63  bindings/python/notmuch/globals.py |   34 ++++++++++++++++++++++------------\r
64  1 files changed, 22 insertions(+), 12 deletions(-)\r
65 \r
66 diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
67 index 32ed9ae..4138460 100644\r
68 --- a/bindings/python/notmuch/globals.py\r
69 +++ b/bindings/python/notmuch/globals.py\r
70 @@ -31,12 +31,34 @@ if sys.version_info[0] == 2:\r
71      class Python3StringMixIn(object):\r
72          def __str__(self):\r
73              return unicode(self).encode('utf-8')\r
74 +\r
75 +\r
76 +    def _str(value):\r
77 +        """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
78 +\r
79 +        C++ code expects strings to be well formatted and\r
80 +        unicode strings to have no null bytes."""\r
81 +        if not isinstance(value, basestring):\r
82 +            raise TypeError("Expected str or unicode, got %s" % type(value))\r
83 +        if isinstance(value, unicode):\r
84 +            return value.encode('UTF-8')\r
85 +        return value\r
86  else:\r
87      class Python3StringMixIn(object):\r
88          def __str__(self):\r
89              return self.__unicode__()\r
90  \r
91  \r
92 +    def _str(value):\r
93 +        """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
94 +\r
95 +        C++ code expects strings to be well formatted and\r
96 +        unicode strings to have no null bytes."""\r
97 +        if not isinstance(value, str):\r
98 +            raise TypeError("Expected str, got %s" % type(value))\r
99 +        return value.encode('UTF-8')\r
100 +\r
101 +\r
102  class Enum(object):\r
103      """Provides ENUMS as "code=Enum(['a','b','c'])" where code.a=0 etc..."""\r
104      def __init__(self, names):\r
105 @@ -202,18 +224,6 @@ class NotInitializedError(NotmuchError):\r
106      status = STATUS.NOT_INITIALIZED\r
107  \r
108  \r
109 -def _str(value):\r
110 -    """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
111 -\r
112 -    C++ code expects strings to be well formatted and\r
113 -    unicode strings to have no null bytes."""\r
114 -    if not isinstance(value, basestring):\r
115 -        raise TypeError("Expected str or unicode, got %s" % str(type(value)))\r
116 -    if isinstance(value, unicode):\r
117 -        return value.encode('UTF-8')\r
118 -    return value\r
119 -\r
120 -\r
121  class NotmuchDatabaseS(Structure):\r
122      pass\r
123  NotmuchDatabaseP = POINTER(NotmuchDatabaseS)\r
124 -- \r
125 1.7.7.3\r
126 \r