Commit 760470ab authored by Vincent Michel's avatar Vincent Michel

Do not ignore non-existing files

parent 1bf1bb85
Pipeline #890 failed with stages
in 1 minute and 4 seconds
......@@ -363,7 +363,11 @@ def get_config_files(path):
def get_config(filename):
"""Read and return the given config file as a dictionary."""
# Make sure the file exists
open(filename).close()
# Customize parser
config = configparser.ConfigParser(
comment_prefixes=['START', 'END', '#', '*****'])
# Read and parse
config.read(filename)
return {section: dict(config[section]) for section in config.sections()}
......@@ -469,3 +469,5 @@ def test_get_config(interface):
d = interface.get_config(filename)
assert d['detector definitions']['alias'] == 'detector1'
assert 'DEFAULT' not in d
with pytest.raises(FileNotFoundError):
interface.get_config('i_dont_exist.ini')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment