From: Patrick Totzke <patricktotzke@googlemail.com>
To: notmuch <notmuch@notmuchmail.org>
Subject: [python] get all messages of a thread
Date: Sat, 28 May 2011 14:18:05 +0100 [thread overview]
Message-ID: <1306588052-sup-9838@brick> (raw)
[-- Attachment #1: Type: text/plain, Size: 1562 bytes --]
Hi!
I wonder how I would get all messages of a thread with the python
bindings. The doc says one can only use Thread.get_toplevel_messages()
and then must recursively call Message.get_replies().
But look:
---------------- snip -------------------------
#/usr/bin/python
from notmuch import Database
def get_thread():
query = Database().create_query('thread:0000000000000c48')
return query.search_threads().next()
def replies(msg):
acc = []
r = msg.get_replies()
if r: #because we cant iterate on NoneType
for m in r:
acc.append(m)
acc += replies(m)
return acc
t=get_thread()
msgs = []
for m in t.get_toplevel_messages():
msgs.append(m)
msgs += replies(m)
print msgs
------------------- snap --------------------
gives:
Traceback (most recent call last):
File "replies.py", line 22, in <module>
msgs +=replies(m)
File "replies.py", line 12, in replies
for m in r:
File "/usr/local/lib/python2.7/dist-packages/notmuch/message.py", line 140, in next
raise NotmuchError(STATUS.NOT_INITIALIZED)
notmuch.globals.NotmuchError: Operation on uninitialized object impossible.
---------------------------------------------
It seems that nobody needed this before. Even in bindings/python/notmuch.py
only Threads.get_toplevel_messages() gets called, and then a (undocumented)
Messages.print_messages is used (cf line 639, in show)
any suggestions?
I would rather not call the notmuch binary and parse its output..
Thanks!
/p
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2011-05-28 13:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-28 13:18 Patrick Totzke [this message]
2011-05-31 23:48 ` [python] get all messages of a thread Carl Worth
2011-06-01 5:35 ` Brian May
2011-06-02 7:05 ` Sebastian Spaeth
2011-06-02 9:43 ` Brian May
2011-06-02 14:20 ` Sebastian Spaeth
2011-06-02 14:37 ` Sebastian Spaeth
2011-06-02 14:38 ` Austin Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306588052-sup-9838@brick \
--to=patricktotzke@googlemail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).