From 8deb71ccea819d7ca5c6b7f491edb1b7c0c6b684 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 19 Jan 2024 10:40:01 -0300 Subject: [PATCH] [Config Reader] Just moved code to make it easier to maintain To ensure VALID_IMPORT is in sync --- kibot/config_reader.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kibot/config_reader.py b/kibot/config_reader.py index 7ec5e7d6..c4aa7ff2 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -527,6 +527,12 @@ class CfgYamlReader(object): fn = outs = filters = vars = globals = pre = groups = None explicit_outs = is_external = False for k, v in entry.items(): + if k not in VALID_IMPORT: + msg = f"Unknown import entry `{k}`" + best_matches = difflib.get_close_matches(k, VALID_IMPORT) + if best_matches: + msg += " (did you mean {}?)".format(' or '.join(best_matches)) + self._config_error_import(fn, msg) if k == 'file': if not isinstance(v, str): raise KiPlotConfigurationError("`import.file` must be a string ({})".format(str(v))) @@ -557,12 +563,6 @@ class CfgYamlReader(object): if not isinstance(v, dict): CfgYamlReader._config_error_import(fn, 'definitions must be a dict') local_defs = v - else: - msg = f"Unknown import entry `{k}`" - best_matches = difflib.get_close_matches(k, VALID_IMPORT) - if best_matches: - msg += " (did you mean {}?)".format(' or '.join(best_matches)) - self._config_error_import(fn, msg) if fn is None: raise KiPlotConfigurationError("`import` entry without `file` ({})".format(str(entry))) else: