From 78edcab86ee9cc0bf50d6ea6ea25f4c3d95c6bec Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Fri, 2 Jul 2021 12:16:20 -0400 Subject: [PATCH] confighelper: don't add supplemental configs to the original Create a new ConfigParser that reads the supplemental and return a new ConfigWrapper. Signed-off-by: Eric Callahan --- moonraker/confighelper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/moonraker/confighelper.py b/moonraker/confighelper.py index 71fe616..a26ee4b 100644 --- a/moonraker/confighelper.py +++ b/moonraker/confighelper.py @@ -121,15 +121,18 @@ class ConfigHelper: return self._get_option( self.config[self.section].getfloat, option, default) - def read_supplemental_config(self, file_name: str) -> None: + def read_supplemental_config(self, file_name: str) -> ConfigHelper: cfg_file_path = os.path.normpath(os.path.expanduser(file_name)) if not os.path.isfile(cfg_file_path): raise ConfigError( f"Configuration File Not Found: '{cfg_file_path}''") try: - self.config.read(cfg_file_path) + sup_cfg = configparser.ConfigParser(interpolation=None) + sup_cfg.read(cfg_file_path) except Exception: raise ConfigError(f"Error Reading Config: '{cfg_file_path}'") + sections = sup_cfg.sections() + return ConfigHelper(self.server, sup_cfg, sections[0], sections) def write_config(self, file_obj: IO[str]) -> None: self.config.write(file_obj)