From aff3a8180a032e686a36327a98ec2e5f12afea8f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Oct 2024 14:54:39 +0200 Subject: [PATCH 1/4] useless --- spcd/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spcd/__init__.py b/spcd/__init__.py index c7622ed..3bfe67a 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -45,11 +45,7 @@ def clone_project_branch() -> None: def install_actions() -> None: - """Make actions usable in workflows. - - :param path: entry point file - :type path: Path - """ + """Make actions usable in workflows.""" step("Install actions") name = "action.yaml" root = project.root / "act" From 7dc9f06e47d65fba3ed42f2735ca920e917e2847 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Oct 2024 14:55:43 +0200 Subject: [PATCH 2/4] 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. From e6d631994e599555ba66576c62bed6756b6b40d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Oct 2024 14:58:34 +0200 Subject: [PATCH 3/4] action --- spcd/act.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spcd/act.py b/spcd/act.py index 625e7fc..5b7c3c2 100644 --- a/spcd/act.py +++ b/spcd/act.py @@ -15,9 +15,8 @@ PREFIX = "INPUT_" def action() -> None: """Display action inputs.""" - for variable, value in sorted(projects.environment.items()): - if variable.startswith(PREFIX): - log.info("%s = %s", variable, value) + for variable, value in parse_inputs().items(): + log.info("%s = %s", variable, value) def parse_inputs() -> dict[str, object]: From 776421884bb4c19eeae4491111adf1d95137ac1c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 21 Oct 2024 15:19:39 +0200 Subject: [PATCH 4/4] removeprefix --- spcd/act.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spcd/act.py b/spcd/act.py index 5b7c3c2..3f6a003 100644 --- a/spcd/act.py +++ b/spcd/act.py @@ -28,7 +28,7 @@ def parse_inputs() -> dict[str, object]: d = {} for variable, value in sorted(projects.environment.items()): if variable.startswith(PREFIX): - d[variable] = literal_eval(value) + d[variable.removeprefix(PREFIX)] = literal_eval(value) return d