From 7515515cb889c6bb8435c7eae923891d6b28dd8e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 16 Mar 2023 19:12:40 +0100 Subject: main: allow -c to be used multiple times Merge values from multiple files. --- alot/settings/manager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'alot/settings/manager.py') diff --git a/alot/settings/manager.py b/alot/settings/manager.py index 15f75cd0..d7a4b499 100644 --- a/alot/settings/manager.py +++ b/alot/settings/manager.py @@ -112,11 +112,12 @@ class SettingsManager: self._notmuchconfig = None self._config = ConfigObj() self._bindings = None + self._config_paths = [] def reload(self): """Reload notmuch and alot config files""" self.read_notmuch_config(self._notmuchconfig.filename) - self.read_config(self._config.filename) + self.read_config(self._config_paths) def read_notmuch_config(self, path): """ @@ -125,7 +126,7 @@ class SettingsManager: :type path: str """ spec = os.path.join(DEFAULTSPATH, 'notmuch.rc.spec') - self._notmuchconfig = read_config(path, spec) + self._notmuchconfig = read_config([path], spec) def _update_bindings(self, newbindings): assert isinstance(newbindings, Section) @@ -134,14 +135,14 @@ class SettingsManager: 'default.bindings')) self._bindings.merge(newbindings) - def read_config(self, path): + def read_config(self, paths): """ parse alot's config file - :param path: path to alot's config file - :type path: str + :param paths: list of config file paths + :type path: list(str) """ spec = os.path.join(DEFAULTSPATH, 'alot.rc.spec') - newconfig = read_config(path, spec, report_extra=True, checks={ + newconfig = read_config(paths, spec, report_extra=True, checks={ 'mail_container': checks.mail_container, 'force_list': checks.force_list, 'align': checks.align_mode, @@ -150,6 +151,8 @@ class SettingsManager: self._config.merge(newconfig) self._config.walk(self._expand_config_values) + self._config_paths = paths + hooks_path = os.path.expanduser(self._config.get('hooksfile')) if os.path.isfile(hooks_path): try: -- cgit v1.2.3