]> git.notmuchmail.org Git - notmuch/commitdiff
bindings/python: add bindings for notmuch_database_get_revision
authorGaute Hope <eg@gaute.vetsj.com>
Mon, 6 Mar 2017 16:37:34 +0000 (17:37 +0100)
committerDavid Bremner <david@tethera.net>
Thu, 9 Mar 2017 14:20:50 +0000 (10:20 -0400)
Database.get_revision () returns a tuple with the current database
revision and the UUID string representing the database.

bindings/python/notmuch/database.py

index 67fb1c41142428ed6c06e36a985de8f1f784a1db..8f918069f34d24ad5059a3a89e0a5e55cd8a8b95 100644 (file)
@@ -86,6 +86,11 @@ class Database(object):
     _get_version.argtypes = [NotmuchDatabaseP]
     _get_version.restype = c_uint
 
+    """notmuch_database_get_revision"""
+    _get_revision = nmlib.notmuch_database_get_revision
+    _get_revision.argtypes = [NotmuchDatabaseP, POINTER(c_char_p)]
+    _get_revision.restype = c_uint
+
     """notmuch_database_open"""
     _open = nmlib.notmuch_database_open
     _open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
@@ -261,6 +266,17 @@ class Database(object):
         self._assert_db_is_initialized()
         return Database._get_version(self._db)
 
+    def get_revision (self):
+        """Returns the committed database revison and UUID
+
+        :returns: (revison, uuid) The database revision as a positive integer
+        and the UUID of the database.
+        """
+        self._assert_db_is_initialized()
+        uuid = c_char_p ()
+        revision = Database._get_revision(self._db, byref (uuid))
+        return (revision, uuid.value.decode ('utf-8'))
+
     _needs_upgrade = nmlib.notmuch_database_needs_upgrade
     _needs_upgrade.argtypes = [NotmuchDatabaseP]
     _needs_upgrade.restype = bool