Skip to content

Commit

Permalink
added separate parsing of graph data to construct mostly similar resu…
Browse files Browse the repository at this point in the history
…lt json-ld
  • Loading branch information
bernd-mueller committed Nov 8, 2024
1 parent e5e5484 commit 7b55b1c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/process_profile_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def getContextFromJSON(self, file):
if i == "@context":
self.context = jay[i]
return self.context

def getGraphFromJSON(self, file):
jay = ""
with open(file) as f:
jay = json.load(f)

for i in jay:
if i == "@graph":
self.graph = jay[i]
return self.graph

def getValidationFromJSON(self, file):
jay = ""
Expand Down Expand Up @@ -111,18 +121,15 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p
# outfile = outputfilename+"."+filetype

outfile = outputfilename
g.serialize(destination=outfile, format="json-ld")
g.serialize(destination=outfile, format="json-ld", auto_compact=True)
print("Writing result to", outfile)
g.close()

jay = ""
with open(outfile) as of:
jay = json.load(of)
jay = self.getGraphFromJSON(outfile)

# print(type(jay))
jaydict = {}
jaydict = dict(ChainMap(*jay))

jaydict.update({"$validation": self.validation})

resDict = {"@context": self.context, "@graph": [jaydict]}
Expand Down

0 comments on commit 7b55b1c

Please sign in to comment.