Skip to content
Snippets Groups Projects
Commit 72376eb6 authored by Marko Mecina's avatar Marko Mecina
Browse files

fix unknown section handling in confignator

- re-run make confignator for changes to take effect
parent 8bf6a356
Branches
Tags
No related merge requests found
...@@ -415,19 +415,18 @@ class Config(configparser.ConfigParser): ...@@ -415,19 +415,18 @@ class Config(configparser.ConfigParser):
:param str option: option name (case insensitive) :param str option: option name (case insensitive)
:param str value: value which should be saved :param str value: value which should be saved
""" """
# find the file where the option is from # find the file where the section/option is from
occurrence = [] occurrence = []
for file in self.files: for file in self.files:
tempcfg = get_config(file_path=file, load_basic_files=False, load_denoted_files=False, check_interpolation=False) tempcfg = get_config(file_path=file, load_basic_files=False, load_denoted_files=False, check_interpolation=False)
found = tempcfg.has_option(section=section, option=option) found = tempcfg.has_section(section=section)
if found is True: if found is True:
occurrence.append(file) occurrence.append(file)
if len(occurrence) == 0: if len(occurrence) == 0:
self.logger.warning('No configuration files with the entry [{}[{}] found'.format(section, option)) self.logger.error('No configuration files with section [{}] found. Saving not possible.'.format(section))
# ToDo: should it be saved as a new section & option? In which file? # self.logger.error('should it be saved as a new section & option?')
self.logger.critical('# ToDo: should it be saved as a new section & option?')
elif len(occurrence) > 1: elif len(occurrence) > 1:
self.logger.error('Found the entry [{}][{}] in more than one configuration file. Saving not possible. Occurrences in: {}'.format(section, option, occurrence)) self.logger.error('Found section [{}] in more than one configuration file. Saving not possible. Occurrences in: {}'.format(section, occurrence))
elif len(occurrence) == 1: elif len(occurrence) == 1:
# load the config (only the specified file, no other) # load the config (only the specified file, no other)
tempcfg = get_config(file_path=occurrence[0], load_basic_files=False, load_denoted_files=False, check_interpolation=False) tempcfg = get_config(file_path=occurrence[0], load_basic_files=False, load_denoted_files=False, check_interpolation=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment