unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Python analogous for the CLI command
@ 2013-04-18  8:11 Flavius Aspra
  2013-04-18 10:26 ` David Bremner
  2013-04-18 10:27 ` Justus Winter
  0 siblings, 2 replies; 3+ messages in thread
From: Flavius Aspra @ 2013-04-18  8:11 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

Hi

Can you give me some pointers on how to use the python module to get the JSON
data with notmuch effort, equivalent to the command:

    notmuch show --entire-thread=true --format=json id:<id>

?

Some key classes and methods would be helpful. From the documentation of the
python code, I couldn't find indications about any of the parameters like
--entire-thread and --format.

Thanks,
Flavius Aspra

-- 
What I cannot create, I do not understand. -- Feynman

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python analogous for the CLI command
  2013-04-18  8:11 Python analogous for the CLI command Flavius Aspra
@ 2013-04-18 10:26 ` David Bremner
  2013-04-18 10:27 ` Justus Winter
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2013-04-18 10:26 UTC (permalink / raw)
  To: flavius.as, notmuch

Flavius Aspra <flavius.as@gmail.com> writes:

> Hi
>
> Can you give me some pointers on how to use the python module to get the JSON
> data with notmuch effort, equivalent to the command:
>
>     notmuch show --entire-thread=true --format=json id:<id>
>
> ?
>
> Some key classes and methods would be helpful. From the documentation of the
> python code, I couldn't find indications about any of the parameters like
> --entire-thread and --format.

I answered this on IRC, but for the archives, this is currently not
possible directly because the json generation code (in fact all of the
output formatting code) does not live in the library, which is what the
bindings bind to.

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python analogous for the CLI command
  2013-04-18  8:11 Python analogous for the CLI command Flavius Aspra
  2013-04-18 10:26 ` David Bremner
@ 2013-04-18 10:27 ` Justus Winter
  1 sibling, 0 replies; 3+ messages in thread
From: Justus Winter @ 2013-04-18 10:27 UTC (permalink / raw)
  To: Flavius Aspra, notmuch

Hi Flavius :)

welcome to notmuch :)

Quoting Flavius Aspra (2013-04-18 10:11:37)
> Can you give me some pointers on how to use the python module to get the JSON
> data with notmuch effort, equivalent to the command:
            ^^^^^^^ hehe :)

Ok, here it is:

teythoon@thinkbox ~/tmp % cat flavius.py
import notmuch

db = notmuch.Database()
q = db.create_query('from:Flavius')

for m in q.search_messages():
    print(m)

for t in q.search_threads():
    for m in t.get_toplevel_messages():
        print(m)
teythoon@thinkbox ~/tmp % python3 flavius.py
Flavius Aspra <flavius.as@gmail.com> (inbox lists notmuch signed) (2013-04-18)
Flavius Aspra <flavius.as@gmail.com> (inbox lists notmuch signed) (2013-04-18)

There once was a json encoder that produced something similar to
notmuch show --format=json, but that was there only to be used by a
python version of the notmuch cli binary. That was unmaintained and
apparently unused, I removed it and the json encoder some time ago.

If you absolutely need json, put the result in some suitable data
structure and use pythons json module to encode it.

> Some key classes and methods would be helpful. From the documentation of the
> python code, I couldn't find indications about any of the parameters like
> --entire-thread and --format.

Have you seen http://notmuch.readthedocs.org ?

Also, if you want to see some code that uses the python bindings, go
to github.com/pazz/alot (nice MUA written in python, but it's huge) or
github.com/teythoon/afew (tagging solution, tiny codebase compared to
alot).

Good luck :)
Justus

btw: cool name ;)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-18 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-18  8:11 Python analogous for the CLI command Flavius Aspra
2013-04-18 10:26 ` David Bremner
2013-04-18 10:27 ` Justus Winter

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