[PATCH 5/9] python: rename _verify_initialized_db to _assert_db_is_initialized

Justus Winter 4winter at informatik.uni-hamburg.de
Sun Sep 25 18:05:33 PDT 2011


Rename the function to clarify its effect and remove all the comments
accompanying each call to the function.

Signed-off-by: Justus Winter <4winter at 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



More information about the notmuch mailing list