From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id E74F86DE0140 for ; Tue, 1 May 2018 17:08:31 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gNNtFyCcruZm for ; Tue, 1 May 2018 17:08:29 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id B4F736DE00F5 for ; Tue, 1 May 2018 17:08:29 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1fDfJr-0005u5-5W; Tue, 01 May 2018 20:08:27 -0400 Received: (nullmailer pid 31336 invoked by uid 1000); Wed, 02 May 2018 00:08:26 -0000 From: David Bremner To: Ruben Pollan , notmuch@notmuchmail.org Subject: Re: [PATCH] python: add bindings for notmuch_message_get_propert(y/ies) In-Reply-To: <20180501152815.20687-1-meskio@sindominio.net> References: <152518827012.10626.6946716348121434660@localhost> <20180501152815.20687-1-meskio@sindominio.net> Date: Tue, 01 May 2018 21:08:26 -0300 Message-ID: <87lgd2gbr9.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Wed, 02 May 2018 00:08:32 -0000 Ruben Pollan writes: > Message.get_property (prop) returns a string with the value of the property and > Message.get_properties (prop, exact=False) yields key, value pairs > --- > bindings/python/docs/source/message.rst | 4 ++ > bindings/python/notmuch/globals.py | 5 +++ > bindings/python/notmuch/message.py | 80 ++++++++++++++++++++++++++++++++- > 3 files changed, 88 insertions(+), 1 deletion(-) > This version passes the first test (after fixing the format, as you noted), but it looks like get_properties is returning pairs of bytestrings. FAIL [15] msg.get_properties (python) --- T610-message-property.16.EXPECTED 2018-05-02 00:02:11.160028179 +0000 +++ T610-message-property.16.OUTPUT 2018-05-02 00:02:11.164028171 +0000 @@ -1,4 +1,4 @@ -testkey1 = alice -testkey1 = bob -testkey1 = testvalue1 -testkey1 = testvalue2 +b'testkey1' = b'alice' +b'testkey1' = b'bob' +b'testkey1' = b'testvalue1' +b'testkey1' = b'testvalue2' I don't _think_ that's what we want. We had some discussion before and decided that it was reasonable to only support utf-8 properties, so converting to strings should be OK? here's the proposed tests. diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh index 74b3f5a1..c903b2b6 100755 --- a/test/T610-message-property.sh +++ b/test/T610-message-property.sh @@ -256,4 +256,34 @@ id:4EFC743A.3060609@april.org EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "msg.get_property (python)" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +msg = db.find_message("4EFC743A.3060609@april.org") +print("testkey1 = {0}".format(msg.get_property("testkey1"))) +print("testkey3 = {0}".format(msg.get_property("testkey3"))) +EOF +cat <<'EOF' > EXPECTED +testkey1 = alice +testkey3 = alice3 +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "msg.get_properties (python)" +test_python <<'EOF' +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) +msg = db.find_message("4EFC743A.3060609@april.org") +for (key,val) in msg.get_properties("testkey1"): + print("{0} = {1}".format(key,val)) +EOF +cat <<'EOF' > EXPECTED +testkey1 = alice +testkey1 = bob +testkey1 = testvalue1 +testkey1 = testvalue2 +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done