Re: Exporting a single email as JSON
authorCiprian Dorin Craciun <ciprian.craciun@gmail.com>
Sun, 11 Dec 2011 01:03:57 +0000 (03:03 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:44 +0000 (09:40 -0800)
98/58b95902533a064fc545178342561a5984776b [new file with mode: 0644]

diff --git a/98/58b95902533a064fc545178342561a5984776b b/98/58b95902533a064fc545178342561a5984776b
new file mode 100644 (file)
index 0000000..b1f7977
--- /dev/null
@@ -0,0 +1,113 @@
+Return-Path: <ciprian.craciun@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id B2A4D429E25\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 17:03:58 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id IGPwMGEZdg-i for <notmuch@notmuchmail.org>;\r
+       Sat, 10 Dec 2011 17:03:58 -0800 (PST)\r
+Received: from mail-iy0-f181.google.com (mail-iy0-f181.google.com\r
+       [209.85.210.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 33C68431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 17:03:58 -0800 (PST)\r
+Received: by iaoo28 with SMTP id o28so6449952iao.26\r
+       for <notmuch@notmuchmail.org>; Sat, 10 Dec 2011 17:03:57 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=mime-version:in-reply-to:references:date:message-id:subject:from:to\r
+       :cc:content-type:content-transfer-encoding;\r
+       bh=tLY/qNwBXmmsh05b9U4kAIMS4kez5+BJA70qGDyQd5k=;\r
+       b=T2xH05wnc09z8tjNSSTbl7UZHX+68nuCL2YEpMNfZMiAtjQHP5K9O5wjzeDMUGOkJK\r
+       51i6ml09dLLqorna+R80HUV8hXg5Qbxl1KE9XDXoLiryPiAA4yVvpA/Eky3Qb7LV/7CX\r
+       qajUrNLnSUJQDE/3o4X+/DU5Inot5Ig3kkOd4=\r
+MIME-Version: 1.0\r
+Received: by 10.182.54.80 with SMTP id h16mr1715660obp.59.1323565437768; Sat,\r
+       10 Dec 2011 17:03:57 -0800 (PST)\r
+Received: by 10.182.222.35 with HTTP; Sat, 10 Dec 2011 17:03:57 -0800 (PST)\r
+In-Reply-To: <878vmk581q.fsf@servo.finestructure.net>\r
+References:\r
+ <CA+Tk8fycS4kmBRABRS4vFQLb3v0-ajcLZwPOwwEf98yvObgpwA@mail.gmail.com>\r
+       <87zkf05gk4.fsf@servo.finestructure.net>\r
+       <CA+Tk8fw+ky6hS0JGLQ4THOf+PSEZhSpfXRF=haayfAdF8HB6PQ@mail.gmail.com>\r
+       <878vmk581q.fsf@servo.finestructure.net>\r
+Date: Sun, 11 Dec 2011 03:03:57 +0200\r
+Message-ID:\r
+ <CA+Tk8fy0xnRuPjuPc9Sz=om9AS9Gwa8fBe+VQjoetO-nJ+kqYg@mail.gmail.com>\r
+Subject: Re: Exporting a single email as JSON\r
+From: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 11 Dec 2011 01:03:58 -0000\r
+\r
+On Sun, Dec 11, 2011 at 01:19, Jameson Graef Rollins\r
+<jrollins@finestructure.net> wrote:\r
+> On Sun, 11 Dec 2011 00:46:51 +0200, Ciprian Dorin Craciun <ciprian.craciu=\r
+n@gmail.com> wrote:\r
+>> =C2=A0 =C2=A0 * in my use-case I would need each line of the output to b=\r
+e a\r
+>> standalone JSON object of an individual message; (thus I can script\r
+>> with Bash `notmuch ... | while read message ; do ... ; done`;)\r
+>\r
+> This is actually a slightly different idea than what I thought you were\r
+> originally proposing. =C2=A0Outputting a series of json objects rather th=\r
+an a\r
+> single list has been talked about for notmuch search as well. =C2=A0I'm d=\r
+on't\r
+> have a good sense of whether this is a sensible idea or not.\r
+>\r
+>> =C2=A0 =C2=A0 * maybe someone else would need that the output to contain\r
+>> **exactly one** such message (maybe the first);\r
+>\r
+> This is what I thought we were talking about. =C2=A0This is an option I w=\r
+ould\r
+> like to see, at least.\r
+\r
+\r
+    Indeed exporting multiple messages as top / root JSON objects\r
+isn't quite usable except limited import / export use-cases, thus what\r
+you propose is more sensible. And in the end by having this\r
+possibility I could easily implement the solution I'm seeking as\r
+simple as:\r
+~~~~\r
+notmuch --output=3Dmessages -- {criteria} \\r
+| xargs -L 1 -- notmuch show --format=3Djson -- \\r
+| while read message_json ; do ... ; done\r
+~~~~\r
+\r
+    But there is only one problem with such an approach: efficiency.\r
+With the snippet above I'll have as many `notmuch` process executions\r
+as messages. (And I do have quite a few of them.) Thus although\r
+Notmuch is quite fast -- as in human imperceptible -- still opening\r
+and closing the Xapian database so many times does have quite an\r
+overhead.\r
+\r
+    So in the end I think a discussion about the needed (/ wanted)\r
+use-cases would be better.\r
+\r
+    Ciprian.\r
+\r
+    P.S.: I could help implement (or at least prototype) some of these\r
+use-cases. Thus I'll watch over the thread you've pointed me to.\r