Skip to content

Commit

Permalink
improve plugin configuration handling
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed May 7, 2024
1 parent baade67 commit 2bc8409
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions lib/galaxy_social.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2bc8409

Please sign in to comment.