From df492e4a7ad2aa00d1a2a424effb5714634921d1 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Thu, 19 Sep 2024 15:47:28 -0400 Subject: [PATCH] Restore @graph top-level key; end with newline A follow-on patch will regenerate Make-managed files. Signed-off-by: Alex Nelson --- src/generate_single_stub_json.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/generate_single_stub_json.py b/src/generate_single_stub_json.py index ec54b3f..972c8ef 100644 --- a/src/generate_single_stub_json.py +++ b/src/generate_single_stub_json.py @@ -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__":