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 A51C7429E25
\r
6 for <notmuch@notmuchmail.org>; Mon, 5 Dec 2011 14:57:15 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "In-Reply-To"
\r
10 X-Spam-Score: -0.799
\r
12 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
13 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
14 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id OYX+l7CLsJp8 for <notmuch@notmuchmail.org>;
\r
18 Mon, 5 Dec 2011 14:57:15 -0800 (PST)
\r
19 Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com
\r
20 [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id BAA20431FB6
\r
23 for <notmuch@notmuchmail.org>; Mon, 5 Dec 2011 14:57:14 -0800 (PST)
\r
24 Received: by eaal13 with SMTP id l13so1502875eaa.26
\r
25 for <notmuch@notmuchmail.org>; Mon, 05 Dec 2011 14:57:13 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
27 d=googlemail.com; s=gamma;
\r
28 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references
\r
29 :in-reply-to; bh=QrVZZYT5y1FJiSs4UfU8BQ3m8ecmV7+FVFjAKOS566Q=;
\r
30 b=VrJSwZ7e21PEjXFroXYdMUDU+QtHHJQQlRs/igqi8/ZbB+vq48CG10oQPz9Uq0prRg
\r
31 zcjsUyX3XURVEnPyjX+NF7ydq47Tg31sy4P8r5VWY+A4f81yT9wJPLyMTRa7vF2ryPd9
\r
32 tIfKYZXkFqUjb5ChMByEd+FzS5UhEI2ujUjlw=
\r
33 Received: by 10.213.23.9 with SMTP id p9mr1570238ebb.147.1323125833454;
\r
34 Mon, 05 Dec 2011 14:57:13 -0800 (PST)
\r
35 Received: from localhost (cpc1-sgyl2-0-0-cust548.18-2.cable.virginmedia.com.
\r
37 by mx.google.com with ESMTPS id 58sm59378566eet.11.2011.12.05.14.57.10
\r
38 (version=TLSv1/SSLv3 cipher=OTHER);
\r
39 Mon, 05 Dec 2011 14:57:12 -0800 (PST)
\r
40 From: patricktotzke@googlemail.com
\r
41 To: notmuch@notmuchmail.org
\r
42 Subject: [PATCH] use __unicode__ for string representation
\r
43 Date: Mon, 5 Dec 2011 22:56:40 +0000
\r
44 Message-Id: <4edd4c48.d2090e0a.3ead.4606@mx.google.com>
\r
45 X-Mailer: git-send-email 1.7.4.1
\r
46 In-Reply-To: <1323119969-1485-3-git-send-email-patricktotzke@gmail.com>
\r
47 References: <1323119969-1485-3-git-send-email-patricktotzke@gmail.com>
\r
48 In-Reply-To: <1323119969-1485-3-git-send-email-patricktotzke@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Mon, 05 Dec 2011 22:57:15 -0000
\r
63 From: Patrick Totzke <patricktotzke@gmail.com>
\r
66 bindings/python/notmuch/filename.py | 3 +++
\r
67 bindings/python/notmuch/globals.py | 11 +++++++----
\r
68 bindings/python/notmuch/message.py | 14 ++++++++------
\r
69 bindings/python/notmuch/tag.py | 5 ++++-
\r
70 4 files changed, 22 insertions(+), 11 deletions(-)
\r
72 diff --git a/bindings/python/notmuch/filename.py b/bindings/python/notmuch/filename.py
\r
73 index 077754e..80755ee 100644
\r
74 --- a/bindings/python/notmuch/filename.py
\r
75 +++ b/bindings/python/notmuch/filename.py
\r
76 @@ -99,6 +99,9 @@ class Filenames(object):
\r
80 + return unicode(self).encode('utf-8')
\r
82 + def __unicode__(self):
\r
83 """Represent Filenames() as newline-separated list of full paths
\r
85 .. note:: As this iterates over the filenames, we will not be
\r
86 diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
\r
87 index 36354fc..62b2df1 100644
\r
88 --- a/bindings/python/notmuch/globals.py
\r
89 +++ b/bindings/python/notmuch/globals.py
\r
90 @@ -49,11 +49,11 @@ class Status(Enum):
\r
93 def status2str(self, status):
\r
94 - """Get a string representation of a notmuch_status_t value."""
\r
95 + """Get a (unicode) string representation of a notmuch_status_t value."""
\r
96 # define strings for custom error messages
\r
97 if status == STATUS.NOT_INITIALIZED:
\r
98 - return "Operation on uninitialized object impossible."
\r
99 - return str(Status._status2str(status))
\r
100 + return u"Operation on uninitialized object impossible."
\r
101 + return unicode(Status._status2str(status))
\r
103 STATUS = Status(['SUCCESS',
\r
105 @@ -133,12 +133,15 @@ class NotmuchError(Exception):
\r
106 self.message = message
\r
109 + return unicode(self).encode('utf-8')
\r
111 + def __unicode__(self):
\r
112 if self.message is not None:
\r
113 return self.message
\r
114 elif self.status is not None:
\r
115 return STATUS.status2str(self.status)
\r
117 - return 'Unknown error'
\r
118 + return u'Unknown error'
\r
120 # List of Subclassed exceptions that correspond to STATUS values and are
\r
121 # subclasses of NotmuchError.
\r
122 diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py
\r
123 index e0c7eda..fac575c 100644
\r
124 --- a/bindings/python/notmuch/message.py
\r
125 +++ b/bindings/python/notmuch/message.py
\r
126 @@ -794,12 +794,14 @@ class Message(object):
\r
127 return self.__str__()
\r
130 - """A message() is represented by a 1-line summary"""
\r
132 - msg['from'] = self.get_header('from')
\r
133 - msg['tags'] = self.get_tags()
\r
134 - msg['date'] = date.fromtimestamp(self.get_date())
\r
135 - return "%(from)s (%(date)s) (%(tags)s)" % (msg)
\r
136 + return unicode(self).encode('utf-8')
\r
138 + def __unicode__(self):
\r
139 + format = "%(from)s (%(date)s) (%(tags)s)"
\r
140 + return format % (self.get_header('from'),
\r
142 + date.fromtimestamp(self.get_date()),
\r
145 def get_message_parts(self):
\r
146 """Output like notmuch show"""
\r
147 diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py
\r
148 index f3a3d27..52607ed 100644
\r
149 --- a/bindings/python/notmuch/tag.py
\r
150 +++ b/bindings/python/notmuch/tag.py
\r
151 @@ -111,7 +111,10 @@ class Tags(object):
\r
152 return self._valid(self._tags) > 0
\r
155 - """The str() representation of Tags() is a space separated list of tags
\r
156 + return unicode(self).encode('utf-8')
\r
158 + def __unicode__(self):
\r
159 + """string representation of :class:`Tags`: a space separated list of tags
\r
161 .. note:: As this iterates over the tags, we will not be able
\r
162 to iterate over them again (as in retrieve them)! If
\r