Re: Hi all
[notmuch-archives.git] / bc / 921a4faad542c411c9ac3cd3877b068970c783
1 Return-Path: <teythoon@jade-hamburg.de>\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 C4FBA431FBC\r
6         for <notmuch@notmuchmail.org>; Thu, 18 Apr 2013 03:28:36 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 PUmn7IoD0ivt for <notmuch@notmuchmail.org>;\r
16         Thu, 18 Apr 2013 03:28:32 -0700 (PDT)\r
17 Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 0DFB9431FBF\r
21         for <notmuch@notmuchmail.org>; Thu, 18 Apr 2013 03:28:32 -0700 (PDT)\r
22 Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [85.183.11.228])\r
23         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
24         (No client certificate requested)\r
25         by mail.cryptobitch.de (Postfix) with ESMTPSA id 5ED6B6211B9\r
26         for <notmuch@notmuchmail.org>; Thu, 18 Apr 2013 12:28:27 +0200 (CEST)\r
27 Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
28         id C0E0EDF2A3; Thu, 18 Apr 2013 12:28:26 +0200 (CEST)\r
29 Received: from thinkbox.jade-hamburg.de (thinkbox.jadE-Hamburg.de\r
30  [10.1.1.109])  (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))     (No\r
31  client certificate requested) (Authenticated sender: teythoon) by\r
32  mail.jade-hamburg.de (Postfix) with ESMTPSA id 24BA7DF28B;     Thu, 18 Apr 2013\r
33  12:28:25 +0200 (CEST)\r
34 Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80)\r
35         (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
36         id 1USm3l-0003HZ-GK; Thu, 18 Apr 2013 12:27:21 +0200\r
37 Content-Type: text/plain; charset="utf-8"\r
38 MIME-Version: 1.0\r
39 Content-Transfer-Encoding: quoted-printable\r
40 From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
41 User-Agent: alot/0.3.3+\r
42 To: Flavius Aspra <flavius.as@gmail.com>,  notmuch@notmuchmail.org\r
43 References: <20130418081137.GA598@evolution>\r
44 In-Reply-To: <20130418081137.GA598@evolution>\r
45 Message-ID: <20130418102721.10489.1439@thinkbox.jade-hamburg.de>\r
46 Subject: Re: Python analogous for the CLI command\r
47 Date: Thu, 18 Apr 2013 12:27:21 +0200\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Thu, 18 Apr 2013 10:28:37 -0000\r
61 \r
62 Hi Flavius :)\r
63 \r
64 welcome to notmuch :)\r
65 \r
66 Quoting Flavius Aspra (2013-04-18 10:11:37)\r
67 > Can you give me some pointers on how to use the python module to get the =\r
68 JSON\r
69 > data with notmuch effort, equivalent to the command:\r
70             ^^^^^^^ hehe :)\r
71 \r
72 Ok, here it is:\r
73 \r
74 teythoon@thinkbox ~/tmp % cat flavius.py\r
75 import notmuch\r
76 \r
77 db =3D notmuch.Database()\r
78 q =3D db.create_query('from:Flavius')\r
79 \r
80 for m in q.search_messages():\r
81     print(m)\r
82 \r
83 for t in q.search_threads():\r
84     for m in t.get_toplevel_messages():\r
85         print(m)\r
86 teythoon@thinkbox ~/tmp % python3 flavius.py\r
87 Flavius Aspra <flavius.as@gmail.com> (inbox lists notmuch signed) (2013-04-=\r
88 18)\r
89 Flavius Aspra <flavius.as@gmail.com> (inbox lists notmuch signed) (2013-04-=\r
90 18)\r
91 \r
92 There once was a json encoder that produced something similar to\r
93 notmuch show --format=3Djson, but that was there only to be used by a\r
94 python version of the notmuch cli binary. That was unmaintained and\r
95 apparently unused, I removed it and the json encoder some time ago.\r
96 \r
97 If you absolutely need json, put the result in some suitable data\r
98 structure and use pythons json module to encode it.\r
99 \r
100 > Some key classes and methods would be helpful. From the documentation of =\r
101 the\r
102 > python code, I couldn't find indications about any of the parameters like\r
103 > --entire-thread and --format.\r
104 \r
105 Have you seen http://notmuch.readthedocs.org ?\r
106 \r
107 Also, if you want to see some code that uses the python bindings, go\r
108 to github.com/pazz/alot (nice MUA written in python, but it's huge) or\r
109 github.com/teythoon/afew (tagging solution, tiny codebase compared to\r
110 alot).\r
111 \r
112 Good luck :)\r
113 Justus\r
114 \r
115 btw: cool name ;)\r