1 Return-Path: <too@guru-group.fi>
\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 8BA8A431FAE
\r
6 for <notmuch@notmuchmail.org>; Wed, 24 Oct 2012 00:00:00 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 cVLve8SfgVK5 for <notmuch@notmuchmail.org>;
\r
16 Tue, 23 Oct 2012 23:59:59 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 25C61431FAF
\r
19 for <notmuch@notmuchmail.org>; Tue, 23 Oct 2012 23:59:59 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id A4B9D100390; Wed, 24 Oct 2012 10:00:01 +0300 (EEST)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 2/2] contrib/nmbug/nmbug-status: combine thread messages
\r
25 Date: Wed, 24 Oct 2012 09:59:59 +0300
\r
26 Message-Id: <1351061999-25473-2-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.7.1
\r
28 In-Reply-To: <1351061999-25473-1-git-send-email-tomi.ollila@iki.fi>
\r
29 References: <1351061999-25473-1-git-send-email-tomi.ollila@iki.fi>
\r
30 Cc: tomi.ollila@iki.fi
\r
31 X-BeenThere: notmuch@notmuchmail.org
\r
32 X-Mailman-Version: 2.1.13
\r
34 List-Id: "Use and development of the notmuch mail system."
\r
35 <notmuch.notmuchmail.org>
\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
37 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
39 List-Post: <mailto:notmuch@notmuchmail.org>
\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
43 X-List-Received-Date: Wed, 24 Oct 2012 07:00:00 -0000
\r
45 Newer patch email containing In-Reply-To: to an email sent some time ago
\r
46 (i.e. to a "thread") was not visible in that "thread" in patch view when
\r
47 another patch "thread" was submitted in between. This change collects
\r
48 all messages in every (notmuch-created) thread together before printing
\r
49 all these threads out in a patch view.
\r
51 Thanks to Ethan Glasser-Camp for initial review and suggestions with
\r
56 Thread class was added for convenience at late time to replace tuple
\r
57 containing last dict & lines list; It could be more utilized -- my excuse
\r
58 of not doing so is to minimize change...
\r
60 OrderedDict could be used in place of threadlist but that requires
\r
61 Python 2.7 (I used python 2.6 where argparse.py was copied to cwd;
\r
62 also nmbug site uses python 2.6...).
\r
64 The table row separator '\n<tr><td colspan="2"><br /></td></tr>\n'
\r
65 is a hack; If someone knows better simple semantic alternative that
\r
66 could be used later...
\r
68 contrib/nmbug/nmbug-status | 73 +++++++++++++++++++++++++++----------------
\r
69 1 files changed, 46 insertions(+), 27 deletions(-)
\r
71 diff --git a/contrib/nmbug/nmbug-status b/contrib/nmbug/nmbug-status
\r
72 index c663409..69b407c 100755
\r
73 --- a/contrib/nmbug/nmbug-status
\r
74 +++ b/contrib/nmbug/nmbug-status
\r
75 @@ -51,12 +51,19 @@ if args.text:
\r
77 output_format = 'html'
\r
79 -headers = ['date', 'from', 'subject']
\r
82 + def __init__(self, last, lines):
\r
84 + self.lines = lines
\r
86 + def join_utf8_with_newlines(self):
\r
87 + return '\n'.join( (line.encode('utf-8') for line in self.lines) )
\r
90 - for header in headers:
\r
92 +def output_with_separator(threadlist, sep):
\r
93 + outputs = (thread.join_utf8_with_newlines() for thread in threadlist)
\r
94 + print sep.join(outputs)
\r
96 +headers = ['date', 'from', 'subject']
\r
98 def print_view(title, query, comment):
\r
100 @@ -64,7 +71,12 @@ def print_view(title, query, comment):
\r
101 q_new = notmuch.Query(db, query_string)
\r
102 q_new.set_sort(notmuch.Query.SORT.OLDEST_FIRST)
\r
104 - last['thread_id'] = ''
\r
105 + last_thread_id = ''
\r
112 if output_format == 'html':
\r
113 print '<h3><a name="%s" />%s</h3>' % (title, title)
\r
114 @@ -77,11 +89,21 @@ def print_view(title, query, comment):
\r
116 for m in q_new.search_messages():
\r
120 thread_id = m.get_thread_id()
\r
121 - if thread_id != last['thread_id']:
\r
124 + if thread_id != last_thread_id:
\r
125 + if threads.has_key(thread_id):
\r
126 + last = threads[thread_id].last
\r
127 + lines = threads[thread_id].lines
\r
131 + thread = Thread(last, lines)
\r
132 + threads[thread_id] = thread
\r
133 + for h in headers:
\r
135 + threadlist.append(thread)
\r
136 + last_thread_id = thread_id
\r
138 for header in headers:
\r
139 val = m.get_header(header)
\r
140 @@ -94,38 +116,35 @@ def print_view(title, query, comment):
\r
142 val = addr.split('@')[0]
\r
144 - if last[header] == val:
\r
145 + if header != 'subject' and last[header] == val:
\r
148 - out[header] = val.encode('utf-8')
\r
149 + out[header] = val
\r
152 mid = m.get_message_id()
\r
153 out['id'] = 'id:"%s"' % mid
\r
155 if output_format == 'html':
\r
156 - # XXX using <br /> is a hack, but ... // 20111216 too
\r
157 - if thread_id != last['thread_id']:
\r
162 out['subject'] = '<a href="http://mid.gmane.org/%s">%s</a>' \
\r
163 % (urllib.quote(mid), out['subject'])
\r
165 - print ' <tr><td>%s %s' % (br, out['date'])
\r
166 - print '</td><td>%s %s' % (br, out['id'])
\r
167 - print '</td></tr>'
\r
168 - print ' <tr><td>%s' % out['from']
\r
169 - print '</td><td>%s' % out['subject']
\r
170 - print '</td></tr>\n'
\r
171 + lines.append(' <tr><td>%s' % out['date'])
\r
172 + lines.append('</td><td>%s' % out['id'])
\r
173 + lines.append('</td></tr>')
\r
174 + lines.append(' <tr><td>%s' % out['from'])
\r
175 + lines.append('</td><td>%s' % out['subject'])
\r
176 + lines.append('</td></tr>')
\r
178 - print '%(date)-10.10s %(from)-20.20s %(subject)-40.40s\n%(id)72s\n' % out
\r
180 - last['thread_id'] = thread_id
\r
181 + lines.append('%(date)-10.10s %(from)-20.20s %(subject)-40.40s\n%(id)72s' % out)
\r
183 if output_format == 'html':
\r
184 + output_with_separator(threadlist,
\r
185 + '\n<tr><td colspan="2"><br /></td></tr>\n')
\r
188 + output_with_separator(threadlist, '\n\n')
\r