Skip to content

Commit

Permalink
Improve generator (#249)
Browse files Browse the repository at this point in the history
We now allow for deep nesting of tests in canonical json

This is needed for kindergarten-garden.
  • Loading branch information
keiravillekode authored Dec 30, 2024
1 parent 2b08ad8 commit 3909c24
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions generators/generate
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ def download_canonical_data(exercise):

def flatten_cases(data):
cases_by_id = {}
for i in data["cases"]:
if "cases" in i:
for j in i["cases"]:
add_case(cases_by_id, j)

def traverse(node):
nonlocal cases_by_id
if "cases" in node:
for child in node["cases"]:
traverse(child)
else:
add_case(cases_by_id, i)
add_case(cases_by_id, node)

traverse(data)
return [cases_by_id[uuid] for uuid in cases_by_id]


Expand Down

0 comments on commit 3909c24

Please sign in to comment.