diff options
| author | Anton Khirnov <anton@khirnov.net> | 2020-06-15 23:55:52 +0200 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2020-06-15 21:50:03 -0300 |
| commit | 5a58754841f4d3e62d104ad338c8ca2c481dc32e (patch) | |
| tree | 20a47fa748153b8c93bffa30db77fea46c03b06d /bindings/python-cffi/notmuch2/_database.py | |
| parent | b7e3a347ac71d2d31747259d4b3bfa089fbaa2b1 (diff) | |
python/notmuch2: add bindings for the database config strings
Diffstat (limited to 'bindings/python-cffi/notmuch2/_database.py')
| -rw-r--r-- | bindings/python-cffi/notmuch2/_database.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bindings/python-cffi/notmuch2/_database.py b/bindings/python-cffi/notmuch2/_database.py index 95f59ca0..3c06402d 100644 --- a/bindings/python-cffi/notmuch2/_database.py +++ b/bindings/python-cffi/notmuch2/_database.py @@ -7,6 +7,7 @@ import pathlib import weakref import notmuch2._base as base +import notmuch2._config as config import notmuch2._capi as capi import notmuch2._errors as errors import notmuch2._message as message @@ -536,6 +537,28 @@ class Database(base.NotmuchObject): self._cached_tagset = weakref.ref(tagset) return tagset + @property + def config(self): + """Return a mutable mapping with the settings stored in this database. + + This returns an mutable dict-like object implementing the + collections.abc.MutableMapping Abstract Base Class. + + :rtype: Config + + :raises ObjectDestroyedError: if used after destroyed. + """ + try: + ref = self._cached_config + except AttributeError: + config_mapping = None + else: + config_mapping = ref() + if config_mapping is None: + config_mapping = config.ConfigMapping(self, '_db_p') + self._cached_config = weakref.ref(config_mapping) + return config_mapping + def _create_query(self, query, *, omit_excluded=EXCLUDE.TRUE, sort=SORT.UNSORTED, # Check this default |
