1 Return-Path: <patricktotzke@googlemail.com>
\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 B1942429E33
\r
6 for <notmuch@notmuchmail.org>; Mon, 5 Dec 2011 13:19:45 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id Pk3NldykS3Uo for <notmuch@notmuchmail.org>;
\r
17 Mon, 5 Dec 2011 13:19:44 -0800 (PST)
\r
18 Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com
\r
19 [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 327BC429E2E
\r
22 for <notmuch@notmuchmail.org>; Mon, 5 Dec 2011 13:19:44 -0800 (PST)
\r
23 Received: by eaal13 with SMTP id l13so1423797eaa.26
\r
24 for <notmuch@notmuchmail.org>; Mon, 05 Dec 2011 13:19:42 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=googlemail.com; s=gamma;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=vUwYoksc2ah1I9qse9lGqpLit8xB069G+mYdGUe+vfI=;
\r
29 b=LGMCisDMM1PEh9F0JhRnoGcSgW7E22aU5dlDfC/QjnsliJZN+M9IKJ+2kGL0enT7CR
\r
30 cJbjsN0pPql39kWjbO+4JJKwhUjk/RHwv0eYu32tTZYf8N/OiG0VG696tSuWXjz5jpd9
\r
31 Fom1wcUJsztfbFimcGK0yr5S8cq6zz5Yq1ETI=
\r
32 Received: by 10.213.3.146 with SMTP id 18mr1397898ebn.6.1323119982817;
\r
33 Mon, 05 Dec 2011 13:19:42 -0800 (PST)
\r
34 Received: from localhost (cpc1-sgyl2-0-0-cust548.18-2.cable.virginmedia.com.
\r
36 by mx.google.com with ESMTPS id v3sm63207905eej.7.2011.12.05.13.19.40
\r
37 (version=TLSv1/SSLv3 cipher=OTHER);
\r
38 Mon, 05 Dec 2011 13:19:41 -0800 (PST)
\r
39 From: Patrick Totzke <patricktotzke@googlemail.com>
\r
40 To: notmuch@notmuchmail.org
\r
41 Subject: [PATCH 2/3] use __unicode__ for string representation
\r
42 Date: Mon, 5 Dec 2011 21:19:28 +0000
\r
43 Message-Id: <1323119969-1485-3-git-send-email-patricktotzke@gmail.com>
\r
44 X-Mailer: git-send-email 1.7.4.1
\r
45 In-Reply-To: <1323119969-1485-1-git-send-email-patricktotzke@gmail.com>
\r
46 References: <1323119969-1485-1-git-send-email-patricktotzke@gmail.com>
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Mon, 05 Dec 2011 21:19:46 -0000
\r
62 bindings/python/notmuch/filename.py | 3 +++
\r
63 bindings/python/notmuch/globals.py | 11 +++++++----
\r
64 bindings/python/notmuch/message.py | 14 ++++++++------
\r
65 bindings/python/notmuch/tag.py | 7 +++++--
\r
66 4 files changed, 23 insertions(+), 12 deletions(-)
\r
68 diff --git a/bindings/python/notmuch/filename.py b/bindings/python/notmuch/filename.py
\r
69 index 077754e..80755ee 100644
\r
70 --- a/bindings/python/notmuch/filename.py
\r
71 +++ b/bindings/python/notmuch/filename.py
\r
72 @@ -99,6 +99,9 @@ class Filenames(object):
\r
76 + return unicode(self).encode('utf-8')
\r
78 + def __unicode__(self):
\r
79 """Represent Filenames() as newline-separated list of full paths
\r
81 .. note:: As this iterates over the filenames, we will not be
\r
82 diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
\r
83 index 36354fc..62b2df1 100644
\r
84 --- a/bindings/python/notmuch/globals.py
\r
85 +++ b/bindings/python/notmuch/globals.py
\r
86 @@ -49,11 +49,11 @@ class Status(Enum):
\r
89 def status2str(self, status):
\r
90 - """Get a string representation of a notmuch_status_t value."""
\r
91 + """Get a (unicode) string representation of a notmuch_status_t value."""
\r
92 # define strings for custom error messages
\r
93 if status == STATUS.NOT_INITIALIZED:
\r
94 - return "Operation on uninitialized object impossible."
\r
95 - return str(Status._status2str(status))
\r
96 + return u"Operation on uninitialized object impossible."
\r
97 + return unicode(Status._status2str(status))
\r
99 STATUS = Status(['SUCCESS',
\r
101 @@ -133,12 +133,15 @@ class NotmuchError(Exception):
\r
102 self.message = message
\r
105 + return unicode(self).encode('utf-8')
\r
107 + def __unicode__(self):
\r
108 if self.message is not None:
\r
109 return self.message
\r
110 elif self.status is not None:
\r
111 return STATUS.status2str(self.status)
\r
113 - return 'Unknown error'
\r
114 + return u'Unknown error'
\r
116 # List of Subclassed exceptions that correspond to STATUS values and are
\r
117 # subclasses of NotmuchError.
\r
118 diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py
\r
119 index e0c7eda..fac575c 100644
\r
120 --- a/bindings/python/notmuch/message.py
\r
121 +++ b/bindings/python/notmuch/message.py
\r
122 @@ -794,12 +794,14 @@ class Message(object):
\r
123 return self.__str__()
\r
126 - """A message() is represented by a 1-line summary"""
\r
128 - msg['from'] = self.get_header('from')
\r
129 - msg['tags'] = self.get_tags()
\r
130 - msg['date'] = date.fromtimestamp(self.get_date())
\r
131 - return "%(from)s (%(date)s) (%(tags)s)" % (msg)
\r
132 + return unicode(self).encode('utf-8')
\r
134 + def __unicode__(self):
\r
135 + format = "%(from)s (%(date)s) (%(tags)s)"
\r
136 + return format % (self.get_header('from'),
\r
138 + date.fromtimestamp(self.get_date()),
\r
141 def get_message_parts(self):
\r
142 """Output like notmuch show"""
\r
143 diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py
\r
144 index f3a3d27..36aeeed 100644
\r
145 --- a/bindings/python/notmuch/tag.py
\r
146 +++ b/bindings/python/notmuch/tag.py
\r
147 @@ -95,7 +95,7 @@ class Tags(object):
\r
148 if not self._valid(self._tags):
\r
150 raise StopIteration
\r
151 - tag = Tags._get(self._tags).decode('UTF-8')
\r
152 + tag = Tags._get(self._tags)
\r
153 self._move_to_next(self._tags)
\r
156 @@ -111,7 +111,10 @@ class Tags(object):
\r
157 return self._valid(self._tags) > 0
\r
160 - """The str() representation of Tags() is a space separated list of tags
\r
161 + return unicode(self).encode('utf-8')
\r
163 + def __unicode__(self):
\r
164 + """string representation of :class:`Tags`: a space separated list of tags
\r
166 .. note:: As this iterates over the tags, we will not be able
\r
167 to iterate over them again (as in retrieve them)! If
\r