diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-11-08 13:21:29 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-11-08 13:22:23 +0000 |
commit | d6ccd7972ec27b538ed1a5a4eb547d0270c29e7b (patch) | |
tree | 9790c611c34fad2a891783cde7b2a74b22abaf8c | |
parent | 95b3eec6d86a2ca05b993c1a2ec9a42dccdf0267 (diff) | |
download | cliapp-d6ccd7972ec27b538ed1a5a4eb547d0270c29e7b.tar.gz |
Require config files specified by --config to exist
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | cliapp/settings.py | 8 |
2 files changed, 8 insertions, 2 deletions
@@ -10,6 +10,8 @@ Bug fix: with an argument. For example, `-e=REGEX`. This has now been fixed to show the correct form, `-eREGEX`, instead. +* If a user specifies a config file with `--config`, it must exist. + Version 1.20150829 ------------------ diff --git a/cliapp/settings.py b/cliapp/settings.py index 896d604..340b594 100644 --- a/cliapp/settings.py +++ b/cliapp/settings.py @@ -296,6 +296,7 @@ class Settings(object): self._add_default_settings() self._config_files = None + self._required_config_files = [] self._cp = ConfigParser.ConfigParser() def _add_default_settings(self): @@ -527,6 +528,7 @@ class Settings(object): def reset_configs(option, opt_str, value, parser): self.config_files = [] + self._required_config_files = [] config_group.add_option( '--no-default-configs', @@ -539,6 +541,7 @@ class Settings(object): def append_to_configs(option, opt_str, value, parser): self.config_files.append(value) + self._required_config_files.append(value) config_group.add_option( '--config', @@ -752,8 +755,9 @@ class Settings(object): for pathname in self.config_files: try: f = open_file(pathname) - except IOError: - pass + except IOError: # pragma: no cover + if pathname in self._required_config_files: + raise else: cp.readfp(f) f.close() |