confighelper: add method to validate configuration

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-02-15 20:37:00 -05:00
parent f229c3ec2c
commit 45557b8260
1 changed files with 15 additions and 0 deletions

View File

@ -95,6 +95,21 @@ class ConfigHelper:
def get_parsed_config(self): def get_parsed_config(self):
return dict(self.parsed) 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): def get_configuration(server, system_args):
cfg_file_path = os.path.normpath(os.path.expanduser( cfg_file_path = os.path.normpath(os.path.expanduser(
system_args.configfile)) system_args.configfile))