a1418e366d6f963aa5ad8c4458aed996207bfd89
4 from pathlib
import Path
9 print("JSON info files script requires ouput file as argument")
12 output_path
= Path(argv
[1])
14 assert getenv("WORK_DIR"), "$WORK_DIR required"
16 work_dir
= Path(getenv("WORK_DIR"))
20 for json_file
in work_dir
.glob("*.json"):
21 image_info
= json
.loads(json_file
.read_text())
23 output
.update(image_info
)
25 # get first (and only) profile in json file
26 device_id
= next(iter(image_info
["profiles"].keys()))
27 if device_id
not in output
["profiles"]:
28 output
["profiles"].update(image_info
["profiles"])
30 output
["profiles"][device_id
]["images"].append(
31 image_info
["profiles"][device_id
]["images"][0]
35 output_path
.write_text(json
.dumps(output
, sort_keys
=True, separators
=(",", ":")))
37 print("JSON info file script could not find any JSON files for target")