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 -------------------------
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 += replies(m)
    return acc

msgs = []
for m in t.get_toplevel_messages():
    msgs += replies(m)

print msgs
------------------- snap --------------------

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..

Attachment: signature.asc
Description: PGP signature

notmuch mailing list

Reply via email to