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 B83D86DE0191 for ; Wed, 29 Nov 2017 13:40:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.168 X-Spam-Level: X-Spam-Status: No, score=0.168 tagged_above=-999 required=5 tests=[AWL=-0.062, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] 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 iONHUY0yqsg4 for ; Wed, 29 Nov 2017 13:40:19 -0800 (PST) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by arlo.cworth.org (Postfix) with ESMTPS id C56726DE00C4 for ; Wed, 29 Nov 2017 13:40:18 -0800 (PST) Received: by mail-wm0-f52.google.com with SMTP id v19so8763681wmh.5 for ; Wed, 29 Nov 2017 13:40:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version; bh=F+Mk1JbvHQVPdcZlNvrnTNIohFcZpLvh5vBw5b8MbPM=; b=rD5F/I4Min2Lmn5gaGVJ0I3Vv5Br7OABuqc9ZrK5fJB1gcTDSig/l4mujHl5vjDQgI GEF1fPwEEToR+9MR07L06BpykON4ix+gQzWuBxepaebNu8XXJZ63mqZNve2F3HJYFyKy 8GlW1MvJKUStOmssQAArB/Emfzb/4Nr8dwcZsyxNo2kzYCU0PwXmBiT+bQjTwR6Yo/07 ERzQb+5CwVgu3v8CDewalv9X6Xo6lSrbkcRKeeK5BVNATiRz97zuldUz7fRvoqSDmdvj HYe5o4yIemp3YfINjAMXPWyAgdYJCBwjf21I2WkTUVf/yiv/7QORRYvuY0Gx3yqz9tIR ykSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:in-reply-to:references :date:message-id:mime-version; bh=F+Mk1JbvHQVPdcZlNvrnTNIohFcZpLvh5vBw5b8MbPM=; b=JSala4aFtS5mFpqJ/J/E6F36NGy8pwtQuaYcSm7ZEELL6sPnNLAMFFdE7WfNnEn+9u iQHtUuFmZ5YS8DTCamyP2u9wZ0Bwqzo7U0F53h3dwNKu6qlS7rWBpHlaPNpry7qcusCJ 9IuCIOW3Tiql5WZnmKGd8nAybhN+Uzk9kWUJPxQK3tTtxGDC8Bl08WwFPfmTuLFJ3vyC MF3i/d6AzXBltej9xquJRrW7JynHTZuNyT8C/rVRGguS8cmOC9xcjPOPHzXxwFUbvirl eK1QAOGpSAGCnpCr/XYf+LPHccXIDuO6+Ki2/oheYX37zWOJsyseU/CT7XsowrEue13e 78oA== X-Gm-Message-State: AJaThX5tyaKOinxVPoc3+Xhygq8k/tJL8ZvXjAAHC3Eqhg2lADd2+jTd 4Dj9vv7nfdzWrJ0m/mwZIrQ3wVq5 X-Google-Smtp-Source: AGs4zMYkpSAyTMpSn9MymsCMosMKEfYqOS6W7imgFBn2Gh7nINbKvzI8QA2typA39myiPdFt9Y8new== X-Received: by 10.80.130.36 with SMTP id 33mr9967185edf.252.1511991617432; Wed, 29 Nov 2017 13:40:17 -0800 (PST) Received: from devork.be ([2a02:168:58e4::7a3]) by smtp.gmail.com with ESMTPSA id p7sm2129207edj.5.2017.11.29.13.40.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Nov 2017 13:40:16 -0800 (PST) Sender: Floris Bruynooghe Received: (nullmailer pid 26618 invoked by uid 1000); Wed, 29 Nov 2017 21:40:15 -0000 From: Floris Bruynooghe To: Daniel Kahn Gillmor , Ruben Pollan , notmuch@notmuchmail.org Subject: Re: [PATCH] python: add bindings for notmuch_message_get_propert(y/ies) In-Reply-To: <87k1y97sor.fsf@fifthhorseman.net> References: <878tf5uvjm.fsf@fifthhorseman.net> <20171128224611.10712-1-meskio@sindominio.net> <87k1y97sor.fsf@fifthhorseman.net> Date: Wed, 29 Nov 2017 22:40:15 +0100 Message-ID: <87tvxcepc0.fsf@devork.be> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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, 29 Nov 2017 21:40:19 -0000 Daniel Kahn Gillmor writes: > On Tue 2017-11-28 23:46:11 +0100, Ruben Pollan wrote: >> Message.get_property (prop) returns a string with the value of the property and >> Message.get_properties (prop, exact=False) returns a list [(key, value)] > > This looks like a sensible approach to me. I'd be curious to hear what > others think of this. > > In considering the API design space here, it occurs to me that it might > be more pythonic for get_properties to return a dict like: I would probably model properties as a dictionary in notdb, making this a collections.abc.MutableMapping implementation with a .get_all(prop) method inspired from the stdlib email.message package. This kind of also implies making properties access a property rather then a method call: msg.properties['prop'] = 'foo' msg.properties['prop'] = 'bar' msg.properties['prop'] == 'foo' # pot luck msg.properties.get_all('prop') == {'foo', 'bar'} # properties are unsorted are they? This also has the binary question problem, is this returned as bytes or as str? Current Python bindings seem to go for .decode('utf-8', errors='ignore') afaik which is somewhat lossy. Cheers, Floris