Expanded logic in replace_placeholder() function so this is easier to work with.

This commit is contained in:
2025-02-25 10:39:07 +01:00
parent 30d49059c5
commit a4335ce8ac
+8 -1
View File
@@ -102,7 +102,14 @@ async def replace_placeholders(meshbook: dict) -> dict:
Replace the placeholders in both name and command fields of the tasks. According to the variables defined in the variables list. Replace the placeholders in both name and command fields of the tasks. According to the variables defined in the variables list.
''' '''
variables = {var["name"]: var["value"] for var in meshbook.get("variables", [])} variables = {}
if "variables" in meshbook and isinstance(meshbook["variables"], list):
for var in meshbook["variables"]:
var_name = var["name"]
var_value = var["value"]
variables[var_name] = var_value
else:
return meshbook
for task in meshbook.get("tasks", []): for task in meshbook.get("tasks", []):
task_name = task.get("name") task_name = task.get("name")