Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E1624431FD0 for ; Sat, 28 May 2011 06:18:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S5nShTU1VSo7 for ; Sat, 28 May 2011 06:18:14 -0700 (PDT) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D1DB7431FB6 for ; Sat, 28 May 2011 06:18:13 -0700 (PDT) Received: by wyi11 with SMTP id 11so2090621wyi.26 for ; Sat, 28 May 2011 06:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:subject:from:to:date:message-id:user-agent :content-transfer-encoding:mime-version:content-type; bh=FR2QpDLDkfj1k2pbyph8uyNtZXaz6Hpe4Uo3yDk0JbM=; b=iPGUFN0akGJkvx4Y4moFkpif6R/NM4OHGXicY0jwqK6ZDZA2IvCBEOl8oOW0iQsV2n 3xD9vSsqc9c38ZLNg0ZLVrh2VLV/iZ+QUKSRfDOgT3S3/tI2W1AjjD8h9xXT2KHL/9ie FFMdlqLp1IEWIhuDioEVA+5YCxE5oFINpZM9E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=subject:from:to:date:message-id:user-agent :content-transfer-encoding:mime-version:content-type; b=BukDbMe8L7oZBj9SnkUudObDBlcDPzz0EnaltolUDt96Mde8KbC4PAl4aFTNZnSzQT ZazHn+TqSfJys35MeLbZzDYq+CsB6HoHjGya05q9BjSZRYXRjDAD26RbZ9D2aBuSAI75 p69sGR+PUg7GSibYtJDQG/ZVM/agkVxolqVIU= Received: by 10.216.140.147 with SMTP id e19mr3043371wej.49.1306588689390; Sat, 28 May 2011 06:18:09 -0700 (PDT) Received: from localhost (cpc1-sgyl2-0-0-cust47.sgyl.cable.virginmedia.com [80.192.18.48]) by mx.google.com with ESMTPS id a1sm1499730wek.46.2011.05.28.06.18.07 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 May 2011 06:18:08 -0700 (PDT) Subject: [python] get all messages of a thread From: Patrick Totzke To: notmuch Date: Sat, 28 May 2011 14:18:05 +0100 Message-Id: <1306588052-sup-9838@brick> User-Agent: Sup/git Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-1306588685-701907-25209-4282-1-="; protocol="application/pgp-signature" X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 May 2011 13:18:15 -0000 --=-1306588685-701907-25209-4282-1-= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D Database().create_query('thread:0000000000000c48') return query.search_threads().next() = def replies(msg): acc =3D [] r =3D msg.get_replies() if r: #because we cant iterate on NoneType for m in r: acc.append(m) acc +=3D replies(m) return acc = t=3Dget_thread() msgs =3D [] for m in t.get_toplevel_messages(): msgs.append(m) msgs +=3D replies(m) print msgs ------------------- snap -------------------- gives: Traceback (most recent call last): File "replies.py", line 22, in msgs +=3Dreplies(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 impossibl= e. --------------------------------------------- It seems that nobody needed this before. Even in bindings/python/notmuch.= py only Threads.get_toplevel_messages() gets called, and then a (undocumente= d) 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 --=-1306588685-701907-25209-4282-1-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk3g9g0ACgkQlDQDZ9fWxapUPACfSgXkAiqUl6gX/oeqjMe3IxQa KXwAnivBb7wQQSPlIhHMyh0b53f8OX5m =TGER -----END PGP SIGNATURE----- --=-1306588685-701907-25209-4282-1-=--