python: add notmuch.Database.status_string()
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Thu, 10 Dec 2015 02:16:40 +0000 (21:16 -0500)
committerJustus Winter <4winter@informatik.uni-hamburg.de>
Fri, 11 Dec 2015 16:05:32 +0000 (17:05 +0100)
This gives some additional access to debugging information when using
the python bindings.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
bindings/python/notmuch/database.py

index 5b58e099b1fde6d692f047d0e32c4ccd9ae0493f..f7d04bf4a5690941ab9367eaa1f6925f70b48483 100644 (file)
@@ -575,6 +575,22 @@ class Database(object):
         """
         return Query(self, querystring)
 
+    """notmuch_database_status_string"""
+    _status_string = nmlib.notmuch_database_status_string
+    _status_string.argtypes = [NotmuchDatabaseP]
+    _status_string.restype = c_char_p
+
+    def status_string(self):
+        """Returns the status string of the database
+
+        This is sometimes used for additional error reporting
+        """
+        self._assert_db_is_initialized()
+        s = Database._status_string(self._db)
+        if s:
+            return s.decode('utf-8', 'ignore')
+        return s
+
     def __repr__(self):
         return "'Notmuch DB " + self.get_path() + "'"