From 2b6c9088c78d1aa944eeb969f678d644b8ef1180 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 20 Nov 2021 14:59:34 +0100 Subject: commands/envelope: refactor deriving headers to be edited Split the code into its own function. Make it properly case-insensitive. Apply either the blacklist or the whitelist setting, trying to apply both makes no sense. Enforce that either a blacklist or a whitelist is configured in the settings. --- alot/settings/manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'alot/settings/manager.py') diff --git a/alot/settings/manager.py b/alot/settings/manager.py index f8ade6df..e4fa48d7 100644 --- a/alot/settings/manager.py +++ b/alot/settings/manager.py @@ -154,6 +154,16 @@ class SettingsManager: tempdir = self._config.get('template_dir') logging.debug('template directory: `%s`' % tempdir) + # validate edit_headers_whitelist/blacklist, which depend on each other + wl = self._config.get('edit_headers_whitelist') + bl = self._config.get('edit_headers_blacklist') + if (wl == ['*']) == (bl == ['*']): + raise ConfigError('Exactly one of "edit_headers_whitelist"', + '"edit_headers_blacklist" must be "*"') + if ('*' in wl and len(wl) > 1) or ('*' in bl and len(bl) > 1): + raise ConfigError('When "*" is used in "edit_headers_whitelist"/' + '"edit_headers_blacklist", it must be the only item.') + # themes themestring = newconfig['theme'] themes_dir = self._config.get('themes_dir') -- cgit v1.2.3