Re: [PATCH 6/7] py3k: Add and use a mixin class that implements __str__
[notmuch-archives.git] / 17 / c4bff7342cc672fdccf53e99b8ba0f18066357
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 23C16429E4C\r
6         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 04:56:56 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 rn-WvPHcWCOa for <notmuch@notmuchmail.org>;\r
16         Wed, 14 Dec 2011 04:56:55 -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 37544429E4A\r
21         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 04:56:55 -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 DC99B50F4C6\r
26         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 13:56:53 +0100 (CET)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id 5BA56DF2A1; Wed, 14 Dec 2011 13:56:53 +0100 (CET)\r
29 Received: from thinkbox.jade-hamburg.de (unknown [85.183.11.228])\r
30         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
31         (No client certificate requested) (Authenticated sender: teythoon)\r
32         by mail.jade-hamburg.de (Postfix) with ESMTPSA id A6597DF29F;\r
33         Wed, 14 Dec 2011 13:56:51 +0100 (CET)\r
34 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
35         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
36         id 1RaoOA-0007ka-G7; Wed, 14 Dec 2011 13:56:50 +0100\r
37 Content-Type: multipart/mixed; boundary="===============2021153055585812822=="\r
38 MIME-Version: 1.0\r
39 References:\r
40  <1323860305-15802-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
41         <1323860305-15802-7-git-send-email-4winter@informatik.uni-hamburg.de>\r
42         <yf6obvbs5j5.fsf@taco2.nixu.fi>\r
43 To: Tomi Ollila <tomi.ollila@iki.fi>,  notmuch@notmuchmail.org\r
44 In-Reply-To: <yf6obvbs5j5.fsf@taco2.nixu.fi>\r
45 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
46 Subject: Re: [PATCH 6/7] py3k: Add and use a mixin class that implements\r
47         __str__\r
48 Date: Wed, 14 Dec 2011 13:56:50 +0100\r
49 Message-Id: <E1RaoOA-0007ka-G7@thinkbox.jade-hamburg.de>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Wed, 14 Dec 2011 12:56:56 -0000\r
63 \r
64 --===============2021153055585812822==\r
65 Content-Type: text/plain; charset="utf-8"\r
66 MIME-Version: 1.0\r
67 Content-Transfer-Encoding: quoted-printable\r
68 \r
69 Quoting Tomi Ollila (2011-12-14 13:26:38)\r
70 >On Wed, 14 Dec 2011 11:58:24 +0100, Justus Winter <4winter@informatik.uni-=\r
71 hamburg.de> wrote:\r
72 >> ---\r
73 >[ ... snip ... ]\r
74 >\r
75 >>  =\r
76 \r
77 >> -class Filenames(object):\r
78 >> +class Filenames(Python3StringMixIn):\r
79 >>      """Represents a list of filenames as returned by notmuch\r
80 >>  =\r
81 \r
82 >>      This object contains the Filenames iterator. The main function is\r
83 >> @@ -98,9 +98,6 @@ class Filenames(object):\r
84 >>  =\r
85 \r
86 >>          self._files =3D None\r
87 >>  =\r
88 \r
89 >> -    def __str__(self):\r
90 >> -        return unicode(self).encode('utf-8')\r
91 >> -\r
92 >>      def __unicode__(self):\r
93 >>          """Represent Filenames() as newline-separated list of full paths\r
94 >>  =\r
95 \r
96 >> diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuc=\r
97 h/globals.py\r
98 >> index c52790c..2111b86 100644\r
99 >> --- a/bindings/python/notmuch/globals.py\r
100 >> +++ b/bindings/python/notmuch/globals.py\r
101 >> @@ -28,6 +28,16 @@ except:\r
102 >>      raise ImportError("Could not find shared 'notmuch' library.")\r
103 >>  =\r
104 \r
105 >>  =\r
106 \r
107 >> +if sys.version_info[0] =3D=3D 2:\r
108 >> +    class Python3StringMixIn(object):\r
109 >> +        def __str__(self):\r
110 >> +            return unicode(self).encode('utf-8')\r
111 >> +else:\r
112 >> +    class Python3StringMixIn(object):\r
113 >> +        def __str__(self):\r
114 >> +            return self.__unicode__()\r
115 >> +\r
116 >> +\r
117 >\r
118 >[ ... snip ... ]\r
119 >\r
120 >> -class Threads(object):\r
121 >> +class Threads(Python3StringMixIn):\r
122 >>      """Represents a list of notmuch threads\r
123 >>  =\r
124 \r
125 >>      This object provides an iterator over a list of notmuch threads\r
126 >> @@ -393,7 +393,7 @@ class Thread(object):\r
127 >>          return Tags(tags_p, self)\r
128 >>  =\r
129 \r
130 >>      def __str__(self):\r
131 >> -        return unicode(self).encode('utf-8')\r
132 >> +        return self.__unicode__().encode('utf-8')\r
133 >>  =\r
134 \r
135 >>      def __unicode__(self):\r
136 >>          frm =3D "thread:%s %12s [%d/%d] %s; %s (%s)"\r
137 >\r
138 >Is this class special case ? in all other classes\r
139 >the __str__() function has been removed (using inherited\r
140 >function) ?\r
141 \r
142 Damn, I missed that one... that was my first approach but that\r
143 obviously didn't worked out... I'll send an updated patch.\r
144 \r
145 >Otherwise LGTM -- pretty simple and effective (all 7 patches).\r
146 \r
147 Thanks :)\r
148 \r
149 Note that I do not know how complete the port is. But the stuff used\r
150 by my tagging application (afew) works.\r
151 \r
152 Justus\r
153 \r
154 --===============2021153055585812822==\r
155 Content-Type: application/octet-stream\r
156 MIME-Version: 1.0\r
157 Content-Transfer-Encoding: base64\r
158 Content-Disposition: attachment; filename=".signature"\r
159 \r
160 bG92ZSB1IGFsb3QgQCxACgo=\r
161 \r
162 --===============2021153055585812822==--\r