Skip to content

Commit

Permalink
Factor out list input parsing into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Dec 14, 2021
1 parent bbc6a81 commit 290bb0f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/normalize_needed_jobs_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ def set_final_result_outputs(job_matrix_succeeded):
set_gha_output(name='success', value=str(job_matrix_succeeded).lower())


def parse_inputs(raw_allowed_failures, raw_jobs):
"""Normalize the action inputs by turning them into data."""
def parse_as_list(input_text):
"""Parse given input as JSON or comma-separated list."""
try:
allowed_failures_input = json.loads(raw_allowed_failures)
return json.loads(input_text)
except json.decoder.JSONDecodeError:
allowed_failures_input = list(
map(str.strip, raw_allowed_failures.split(',')),
)
return [s.strip() for s in input_text.split(',')]


def parse_inputs(raw_allowed_failures, raw_jobs):
"""Normalize the action inputs by turning them into data."""
allowed_failures_input = parse_as_list(raw_allowed_failures)


return {
Expand Down

0 comments on commit 290bb0f

Please sign in to comment.