From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wKP4L2ht0GFLPQEAgWs5BA (envelope-from ) for ; Sat, 01 Jan 2022 16:04:08 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id qJ5KLWht0GFlMwEA9RJhRA (envelope-from ) for ; Sat, 01 Jan 2022 16:04:08 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 555D231C19 for ; Sat, 1 Jan 2022 16:04:03 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DBBEF5F713; Sat, 1 Jan 2022 15:03:58 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by mail.notmuchmail.org (Postfix) with ESMTPS id 548645F5EE for ; Sat, 1 Jan 2022 15:03:56 +0000 (UTC) Received: by mail-wm1-x332.google.com with SMTP id o30so16313707wms.4 for ; Sat, 01 Jan 2022 07:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=yzQyT9wP2kQTSaMwMkgdwyweh9dbt8cyGltKvZV4UsY=; b=ZcF2bKLNI3ENnuYvaHa/PWQnQv/MdS3AukrT8paNVBSmOn1Ea695mcsXZ09vo5NcNW uy3U/8iTeW7L6n93X8O0p2UNLapjw/hJvq3CCAa24O5PPoCWWXVCEEbOLCI6K3HiOeDb j4pTc8MBqGIe/DgzkPKqosRqgS1SkUu39L26yVZ89/GGrAEWxETea/OoWtMqWmMRgAsO hzKD43D2HOlN9CSdyrWvhBJaxfs3JTEwRG1PutRurLBMTCv+htU/OHcWDjcyxWC48ygV g5HNzFChqFXPnfsC0LXuUPltDgEVWe3tyYSVINc1Yoo2xwzhZu60RJJuhrjUciT9ykWi f0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :date:message-id:mime-version; bh=yzQyT9wP2kQTSaMwMkgdwyweh9dbt8cyGltKvZV4UsY=; b=Z93jdwBeX7QW7aVvDvzUAUNPlJ3xClemKOV2zBumvK/waIe349V9B0wK7c0JwbKn0Z eDZHnUFUMoW8BW3xopN6IW1bHtv7Wt7hb0dQ+vqzsqQZzYROK5uUO5iJ3u3WNEq9YATy 6T/zLTRIPMII9YCz6xen/usys1VIGqc7D0oqwaRdLHNhz/ETXWr+/s29gWHJXZwwD2JW aji37J0mCQAtQ06clem8dr1ZzpYWMNBTTLF7c189OisyzAx+hvEtSykJsIId8bh9y3Cn mssE0Qbc0r8HOMOvo9I+9yCuEI0YHsPCI/XNjp+WdJJpCRTeXtuVe1TMXjoxBaE9ylwh /rIQ== X-Gm-Message-State: AOAM532K2j2MfuEHKPMfTCan+FKQ0tqp89wmxcge8ANfoW/ZpUp2ZhtT BNVupIrLPhF8kbzjMuivYMc= X-Google-Smtp-Source: ABdhPJwzSDxdPHr3GxMa19YX2Q/pAplkp3o8V3mzQYLpIbQ6L7VZOu+zMIceT7tdGKe+/DmA9Q/ARA== X-Received: by 2002:a7b:c745:: with SMTP id w5mr32224169wmk.167.1641049435506; Sat, 01 Jan 2022 07:03:55 -0800 (PST) Received: from powell.devork.be (62-178-226-148.cable.dynamic.surfer.at. [62.178.226.148]) by smtp.gmail.com with ESMTPSA id 11sm38138013wrz.63.2022.01.01.07.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jan 2022 07:03:55 -0800 (PST) Sender: Floris Bruynooghe Received: (nullmailer pid 11405 invoked by uid 1000); Sat, 01 Jan 2022 15:03:53 -0000 From: Floris Bruynooghe To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH] bindings/python-cffi: add matched property to message objects In-Reply-To: <20220101144228.161473-1-david@tethera.net> References: <20220101144228.161473-1-david@tethera.net> Date: Sat, 01 Jan 2022 16:03:53 +0100 Message-ID: <87ee5rlcpy.fsf@powell.devork.be> MIME-Version: 1.0 Message-ID-Hash: DUFUNHGNEIRPHT4SEK5QRVMBP2M5YL3M X-Message-ID-Hash: DUFUNHGNEIRPHT4SEK5QRVMBP2M5YL3M X-MailFrom: floris.bruynooghe@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641049443; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ODWSuaPl+XR2s62CehpQAzbnbc59XucWA01AgJaTLdg=; b=XkLjx56Ha0gJtBjYupjH5Yqi61Z5eHpWFSKFUSBLf1Biyb8Id3Nh9vnJojxP9WsbYUqx98 4qlgQOyLM1VzZpta1IieHAM2iqwr9pQ+3VegV9FDnS773a+mUbVXOfIyZaFYNa1Wy7WLgp sLZlIBzgXDi5nfXVloWL9W6LMDCf3L2z0GF5Tt+5NAF1A/kvl3NWFt1BqGjiMoaTxvrMn+ G4hJTCqsXDtjaVmSmi9sqr35jo5nhdSvzr0vYm8qK0wcurOTMIxSbAosIM882Lz1GYkYxZ Dl0c4Ejs/iLw04ZTJElSedxalp5Fmzz625W/jeQvz4xsIRL89v1IIsTj8FR1rg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641049443; a=rsa-sha256; cv=none; b=qkwI7iUfZyxayY5xkSt0wTPcIt4yjUB67qwhTUxviEtvdKK52D9HdcKgdVKP/DN+AlzXmf WfVrCeRigIgMv8QaR2pWk7Cr3h1CwDDWh2MtQf3hKzXPrMEKEf4Z96Uwg5y652l2mPwv6V 443e/LFAGqIz0wrWplcIqI6LGKBOJNHrYUtJNgmmg51cjFbKQLoanOEtXnG4+xDTxoP+W8 hZfGap5KoDsGiKnr2rvEB6NBpE5mg99oGv+1v6NjBSBIoEwX2L3mA64/KRNxVBdzbQu372 Dv/QVBpd35mt103AlueONpMEIkIUMHfkETMogfvBgpfjwVWQYmh02jZT9JTv7w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=ZcF2bKLN; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.27 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=ZcF2bKLN; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 555D231C19 X-Spam-Score: -1.27 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8Z14ZbVgLyxV On Sat 01 Jan 2022 at 10:42 -0400, David Bremner wrote: > Existing users of the legacy python bindings use > message.get_flags(Message.FLAG.MATCH) to determine which messages in a > thread matched. Since the bindings don't provide get_flags anymore, > they should provide a property analogous to the existing "excluded" > property. > --- > bindings/python-cffi/notmuch2/_message.py | 14 ++++++++++++++ > bindings/python-cffi/tests/test_message.py | 3 +++ > bindings/python-cffi/tests/test_thread.py | 7 +++++++ > 3 files changed, 24 insertions(+) > > diff --git a/bindings/python-cffi/notmuch2/_message.py b/bindings/python-cffi/notmuch2/_message.py > index 2f232076..a460d8c1 100644 > --- a/bindings/python-cffi/notmuch2/_message.py > +++ b/bindings/python-cffi/notmuch2/_message.py > @@ -205,6 +205,20 @@ class Message(base.NotmuchObject): > self._msg_p, capi.lib.NOTMUCH_MESSAGE_FLAG_EXCLUDED) > return bool(ret) > > + @property > + def matched(self): > + """Indicates whether this message was matched by the query. > + > + When a thread is created from a search, some of the > + messages may not match the original query. This property > + is set to *True* for those that do match. > + > + :raises ObjectDestroyedError: if used after destroyed. > + """ > + ret = capi.lib.notmuch_message_get_flag( > + self._msg_p, capi.lib.NOTMUCH_MESSAGE_FLAG_MATCH) > + return bool(ret) > + > @property > def date(self): > """The message date as an integer. > diff --git a/bindings/python-cffi/tests/test_message.py b/bindings/python-cffi/tests/test_message.py > index 532bf921..56701d05 100644 > --- a/bindings/python-cffi/tests/test_message.py > +++ b/bindings/python-cffi/tests/test_message.py > @@ -97,6 +97,9 @@ class TestMessage: > def test_ghost_no(self, msg): > assert not msg.ghost > > + def test_matched_no(self,msg): > + assert not msg.matched > + > def test_date(self, msg): > # XXX Someone seems to treat things as local time instead of > # UTC or the other way around. > diff --git a/bindings/python-cffi/tests/test_thread.py b/bindings/python-cffi/tests/test_thread.py > index 1f44b35d..fbef73ac 100644 > --- a/bindings/python-cffi/tests/test_thread.py > +++ b/bindings/python-cffi/tests/test_thread.py > @@ -57,6 +57,13 @@ def test_iter(thread): > def test_matched(thread): > assert thread.matched == 1 > > +def test_matched_iter(thread): > + count = 0 > + msgs = list(iter(thread)) > + for msg in msgs: > + if msg.matched: > + count += 1 > + assert count == thread.matched > > def test_authors_type(thread): > assert isinstance(thread.authors, notmuch2.BinString) LGTM