From 45557b82600beb6e42681ea46af414cc8d816d52 Mon Sep 17 00:00:00 2001 From: Arksine Date: Mon, 15 Feb 2021 20:37:00 -0500 Subject: [PATCH] confighelper: add method to validate configuration Signed-off-by: Eric Callahan --- moonraker/confighelper.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/moonraker/confighelper.py b/moonraker/confighelper.py index 0466441..951a729 100644 --- a/moonraker/confighelper.py +++ b/moonraker/confighelper.py @@ -95,6 +95,21 @@ class ConfigHelper: def get_parsed_config(self): return dict(self.parsed) + def validate_config(self): + for sect in self.orig_sections: + if sect not in self.parsed: + logging.warn( + f"Invalid config section [{sect}] detected. In " + "the future this will result in a startup error") + continue + parsed_opts = self.parsed[sect] + for opt, val in self.config.items(sect): + if opt not in parsed_opts: + logging.warn( + f"Invalid option '{opt}' detected in section " + f"[{sect}]. In the future this will result in a " + "startup error.") + def get_configuration(server, system_args): cfg_file_path = os.path.normpath(os.path.expanduser( system_args.configfile))