From 7dc9f06e47d65fba3ed42f2735ca920e917e2847 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Oct 2024 14:55:43 +0200 Subject: [PATCH] parse_inputs --- spcd/act.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/spcd/act.py b/spcd/act.py index 203528e..625e7fc 100644 --- a/spcd/act.py +++ b/spcd/act.py @@ -1,6 +1,7 @@ """Actions available for workflows.""" import os +from ast import literal_eval from pathlib import Path from rwx import ps @@ -9,15 +10,29 @@ from rwx.log import stream as log from spcd.ci import project, projects from spcd.shell import env +PREFIX = "INPUT_" + def action() -> None: """Display action inputs.""" - prefix = "INPUT_" for variable, value in sorted(projects.environment.items()): - if variable.startswith(prefix): + if variable.startswith(PREFIX): log.info("%s = %s", variable, value) +def parse_inputs() -> dict[str, object]: + """Parse inputs as a dictionary. + + :return: name & value pairs + :rtype: dict[str, object] + """ + d = {} + for variable, value in sorted(projects.environment.items()): + if variable.startswith(PREFIX): + d[variable] = literal_eval(value) + return d + + def synchronize(source: str | None = None, target: str | None = None) -> None: """Synchronize output towards a target.