From b83f642a13a37a23838842e4d8d70b461e209491 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Sun, 17 Dec 2023 18:03:42 +0100 Subject: [PATCH] refactor(ConfigManager): logging can be silenced Signed-off-by: Dominik Willner --- kiauh/core/config_manager/config_manager.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kiauh/core/config_manager/config_manager.py b/kiauh/core/config_manager/config_manager.py index 593773f..00cc41b 100644 --- a/kiauh/core/config_manager/config_manager.py +++ b/kiauh/core/config_manager/config_manager.py @@ -32,15 +32,17 @@ class ConfigManager: with open(self.config_file, "w") as cfg: self.config.write(cfg) - def get_value(self, section: str, key: str) -> Union[str, bool, None]: + def get_value(self, section: str, key: str, silent=False) -> Union[str, bool, None]: if not self.config.has_section(section): - log = f"Section not defined. Unable to read section: [{section}]." - Logger.print_error(log) + if not silent: + log = f"Section not defined. Unable to read section: [{section}]." + Logger.print_error(log) return None if not self.config.has_option(section, key): - log = f"Option not defined in section [{section}]. Unable to read option: '{key}'." - Logger.print_error(log) + if not silent: + log = f"Option not defined in section [{section}]. Unable to read option: '{key}'." + Logger.print_error(log) return None value = self.config.get(section, key)