]> git.notmuchmail.org Git - notmuch/commitdiff
python: support relative path in default database
authorDoan Tran Cong Danh <congdanhqx@gmail.com>
Fri, 19 Apr 2019 03:56:59 +0000 (10:56 +0700)
committerDavid Bremner <david@tethera.net>
Wed, 24 Apr 2019 10:10:53 +0000 (07:10 -0300)
From notmuch 0.28, notmuch support relative database path in
notmuch-config(1), but python binding haven't taught this yet.

afew denied to work with a perfectly fine notmuch-config due to this.

bindings/python/notmuch/database.py

index 342d665a224761a2557ea00233f7d99c7dbae321..88ca836e2d1aa4c78471ede28f7541fac630aafa 100644 (file)
@@ -675,7 +675,10 @@ class Database(object):
         if not config.has_option('database', 'path'):
             raise NotmuchError(message="No DB path specified"
                                        " and no user default found")
         if not config.has_option('database', 'path'):
             raise NotmuchError(message="No DB path specified"
                                        " and no user default found")
-        return config.get('database', 'path')
+        db_path = config.get('database', 'path')
+        if not os.path.isabs(db_path):
+            db_path = os.path.expanduser(os.path.join("~", db_path))
+        return db_path
 
     """notmuch_database_get_config"""
     _get_config = nmlib.notmuch_database_get_config
 
     """notmuch_database_get_config"""
     _get_config = nmlib.notmuch_database_get_config