confighelper: raise duplicate exceptions
Moonraker requires that the configuration be parsed in 'strict' mode, ie: duplicate sections are not allowed within the same file and duplicate options are not allowed within the same section. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
78605db001
commit
e8999363ed
|
@ -986,7 +986,10 @@ class FileSourceWrapper(ConfigSourceWrapper):
|
|||
if section not in self.file_section_map:
|
||||
self.file_section_map[section] = []
|
||||
elif file_index in self.file_section_map[section]:
|
||||
self.file_section_map[section].remove(file_index)
|
||||
raise ConfigError(
|
||||
f"Duplicate section [{section}] in file "
|
||||
f"{file_path}"
|
||||
)
|
||||
self.file_section_map[section].insert(0, file_index)
|
||||
else:
|
||||
# This line must specify an option
|
||||
|
@ -996,7 +999,10 @@ class FileSourceWrapper(ConfigSourceWrapper):
|
|||
if key not in self.file_option_map:
|
||||
self.file_option_map[key] = []
|
||||
elif file_index in self.file_option_map[key]:
|
||||
self.file_option_map[key].remove(file_index)
|
||||
raise ConfigError(
|
||||
f"Duplicate option '{option}' in section "
|
||||
f"[{last_section}], file {file_path} "
|
||||
)
|
||||
self.file_option_map[key].insert(0, file_index)
|
||||
buffer.append(line)
|
||||
self._write_buffer(buffer, file_path)
|
||||
|
|
Loading…
Reference in New Issue