From 2bc84092d7f6b49ea630147e986fca4e0130fff6 Mon Sep 17 00:00:00 2001 From: Arash Date: Tue, 7 May 2024 13:32:28 +0200 Subject: [PATCH] improve plugin configuration handling --- lib/galaxy_social.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/galaxy_social.py b/lib/galaxy_social.py index 184964d..03296bb 100644 --- a/lib/galaxy_social.py +++ b/lib/galaxy_social.py @@ -37,23 +37,20 @@ def __init__(self, preview: bool, json_out: str): f"Error with plugin {module_name}.{class_name}.\n{e}" ) - try: - config = {} - if plugin.get("config"): - for key, value in plugin["config"].items(): - if isinstance(value, str) and value.startswith("$"): - try: - config[key] = os.environ[value[1:]] - except KeyError: - raise Exception( - f"Missing environment variable {value[1:]}." - ) - else: - config[key] = value - except Exception as e: - raise Exception( - f"Missing config for {module_name}.{class_name}.\n{e}" - ) + config = {} + if plugin.get("config"): + for key, value in plugin["config"].items(): + if isinstance(value, str) and value.startswith("$"): + try: + config[key] = os.environ[value[1:]] + except KeyError: + raise Exception( + f"Missing environment variable {value[1:]}." + ) + else: + config[key] = value + else: + raise Exception(f"Missing config for {module_name}.{class_name}.") try: self.plugins[plugin["name"].lower()] = plugin_class(**config)