Skip to content

Commit

Permalink
Restore @graph top-level key; end with newline
Browse files Browse the repository at this point in the history
A follow-on patch will regenerate Make-managed files.

Signed-off-by: Alex Nelson <[email protected]>
  • Loading branch information
ajnelson-nist committed Sep 19, 2024
1 parent 44cc661 commit df492e4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/generate_single_stub_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,17 @@ def main() -> None:
compacted_graph = pyld.jsonld.compact(expanded_stub, context)
swap_values(compacted_graph, 9, None)

# Guarantee "@graph" key is used and list-valued.
if "@graph" not in compacted_graph.keys():
new_graph: Dict[str, JSON] = dict()
new_graph["@context"] = compacted_graph["@context"]
del compacted_graph["@context"]
new_graph["@graph"] = [compacted_graph]
compacted_graph = new_graph

with open(args.out_json, "w") as out_fh:
json.dump(compacted_graph, out_fh, indent=4, sort_keys=True)
out_fh.write("\n")


if __name__ == "__main__":
Expand Down

0 comments on commit df492e4

Please sign in to comment.