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 867EE6DE0183 for ; Thu, 7 Dec 2017 03:54:49 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.71 X-Spam-Level: X-Spam-Status: No, score=-0.71 tagged_above=-999 required=5 tests=[AWL=0.020, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 A5N8NrwIDnu4 for ; Thu, 7 Dec 2017 03:54:49 -0800 (PST) Received: from mout.web.de (mout.web.de [212.227.15.14]) by arlo.cworth.org (Postfix) with ESMTPS id 617386DE009B for ; Thu, 7 Dec 2017 03:54:48 -0800 (PST) Received: from localhost ([78.53.227.28]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lx73h-1f70uc3fUf-016ihq; Thu, 07 Dec 2017 12:42:16 +0100 From: l-m-h@web.de To: notmuch@notmuchmail.org Cc: Lucas Hoffmann Subject: [PATCH 2/6] python: add default arg to get_config_list Date: Thu, 7 Dec 2017 12:40:47 +0100 Message-Id: <85aaf32f62f7c732a6f20255d0f60a13752c0849.1512646265.git.l-m-h@web.de> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: <8737am9w18.fsf@tethera.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.15.1" X-Provags-ID: V03:K0:TmqUufaXzeeVW83G44R3k+gbzROEZ/BLZGrlbGswfAh7sXhzh0E ODV7saxBMLyvFoE2BPHHdW183Oi0xB4YC6J9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, 07 Dec 2017 11:31:51 -0800 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: Thu, 07 Dec 2017 11:54:49 -0000 From: Lucas Hoffmann This is a multi-part message in MIME format. --------------2.15.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit It makes the function a little more intuitive to use and does not diverge much from the original function signature. Also an example is added to the docstring. --- bindings/python/notmuch/database.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --------------2.15.1 Content-Type: text/x-patch; name="0002-python-add-default-arg-to-get_config_list.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0002-python-add-default-arg-to-get_config_list.patch" diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index 2866b860..54966307 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -313,7 +313,7 @@ class Database(object): """ self._assert_db_is_initialized() status = Database._upgrade(self._db, None, None) - #TODO: catch exceptions, document return values and etc + # TODO: catch exceptions, document return values and etc return status _begin_atomic = nmlib.notmuch_database_begin_atomic @@ -689,12 +689,19 @@ class Database(object): _config_list_destroy.argtypes = [NotmuchConfigListP] _config_list_destroy.restype = None - def get_config_list(self, prefix): + def get_config_list(self, prefix=''): """Return a list of key, value pairs where the start of key matches the given prefix Note that only config values that are stored in the database are - searched and returned. The config file is not read. + searched and returned. The config file is not read. If no `prefix` is + given all config values are returned. + + This could be used to get all config values or all named queries into a + dict for example:: + + config = {k: v for k, v in db.get_config_list()} + queries = {k[6:]: v for k, v in db.get_config_list('query.')} :param prefix: a string by which the keys should be selected :type prefix: str --------------2.15.1--