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 25C4A431FD0 for ; Sun, 25 Sep 2011 18:06:35 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 46Nmn793Eybl for ; Sun, 25 Sep 2011 18:06:34 -0700 (PDT) Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 2F0B9431FB6 for ; Sun, 25 Sep 2011 18:06:34 -0700 (PDT) Received: from mail.jade-hamburg.de (unknown [85.183.11.228]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cryptobitch.de (Postfix) with ESMTPSA id EF4F0505B24 for ; Mon, 26 Sep 2011 03:06:32 +0200 (CEST) Received: by mail.jade-hamburg.de (Postfix, from userid 401) id 72AB0DF2A6; Mon, 26 Sep 2011 03:06:32 +0200 (CEST) Received: from thinkbox.jade-hamburg.de (unknown [10.1.1.109]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: teythoon) by mail.jade-hamburg.de (Postfix) with ESMTPSA id 230CBDF2A1; Mon, 26 Sep 2011 03:06:14 +0200 (CEST) Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.76) (envelope-from ) id 1R7ze5-0007OP-By; Mon, 26 Sep 2011 03:06:09 +0200 From: Justus Winter <4winter@informatik.uni-hamburg.de> To: notmuch@notmuchmail.org Subject: [PATCH 5/9] python: rename _verify_initialized_db to _assert_db_is_initialized Date: Mon, 26 Sep 2011 03:05:33 +0200 Message-Id: <1316999137-28257-5-git-send-email-4winter@informatik.uni-hamburg.de> X-Mailer: git-send-email 1.7.6.3 In-Reply-To: <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de> References: <1316999137-28257-1-git-send-email-4winter@informatik.uni-hamburg.de> X-Mailman-Approved-At: Mon, 26 Sep 2011 09:17:56 -0700 Cc: Justus Winter <4winter@informatik.uni-hamburg.de> 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: Mon, 26 Sep 2011 01:06:35 -0000 Rename the function to clarify its effect and remove all the comments accompanying each call to the function. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de> --- bindings/python/notmuch/database.py | 32 +++++++++++--------------------- 1 files changed, 11 insertions(+), 21 deletions(-) diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index e174f55..ecc5c17 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -105,7 +105,7 @@ class Database(object): else: self.create(path) - def _verify_initialized_db(self): + def _assert_db_is_initialized(self): """Raises a NotmuchError in case self._db is still None""" if self._db is None: raise NotmuchError(status=STATUS.NOT_INITIALIZED) @@ -161,8 +161,7 @@ class Database(object): """Returns the file path of an open database Wraps *notmuch_database_get_path*.""" - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() return Database._get_path(self._db).decode('utf-8') @@ -173,8 +172,7 @@ class Database(object): :exception: :exc:`NotmuchError` with STATUS.NOT_INITIALIZED if the database was not intitialized. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() return Database._get_version(self._db) @@ -190,8 +188,7 @@ class Database(object): :exception: :exc:`NotmuchError` with STATUS.NOT_INITIALIZED if the database was not intitialized. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() return nmlib.notmuch_database_needs_upgrade(self._db) @@ -210,8 +207,7 @@ class Database(object): :TODO: catch exceptions, document return values and etc... """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() status = Database._upgrade(self._db, None, None) #TODO: catch exceptions, document return values and etc @@ -239,8 +235,7 @@ class Database(object): components same as database. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() # sanity checking if path is valid, and make path absolute if path[0] == os.sep: @@ -310,8 +305,7 @@ class Database(object): STATUS.NOT_INITIALIZED The database has not been initialized. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() msg_p = c_void_p() status = nmlib.notmuch_database_add_message(self._db, @@ -357,8 +351,7 @@ class Database(object): STATUS.NOT_INITIALIZED The database has not been initialized. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() return nmlib.notmuch_database_remove_message(self._db, filename) @@ -381,8 +374,7 @@ class Database(object): :exception: :exc:`NotmuchError` with STATUS.NOT_INITIALIZED if the database was not intitialized. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() msg_p = Database._find_message(self._db, _str(msgid)) return msg_p and Message(msg_p, self) or None @@ -393,8 +385,7 @@ class Database(object): :returns: :class:`Tags` :execption: :exc:`NotmuchError` with STATUS.NULL_POINTER on error """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() tags_p = Database._get_all_tags(self._db) if tags_p == None: @@ -419,8 +410,7 @@ class Database(object): This function is a python extension and not in the underlying C API. """ - # Raise a NotmuchError if not initialized - self._verify_initialized_db() + self._assert_db_is_initialized() return Query(self, querystring) -- 1.7.6.3