Skip to content

Commit

Permalink
added auto_compact parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bernd-mueller committed Nov 5, 2024
1 parent 73ba369 commit 3190dbb
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/process_profile_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,33 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p
# save the graph with additional profile triples
# 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()
postproc = """
{
"@context": {
"schema": "http://schema.org/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"bioschemas": "https://discovery.biothings.io/view/bioschemas/"
},
"@graph":
"""

print("Postprocessing file to legit Bioschemas file format.")

enriched = ""
with open(outfile, 'r') as file:
for line in file:
enriched += line.strip() + "\n"
file.close()

postproc = postproc + enriched + "\n}"

with open(outfile, "w") as file:
file.write(postproc)
file.close()
# postproc = """
# {
# "@context": {
# "schema": "http://schema.org/",
# "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
# "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
# "bioschemas": "https://discovery.biothings.io/view/bioschemas/"
# },
# "@graph":
# """

# print("Postprocessing file to legit Bioschemas file format.")

# enriched = ""
# with open(outfile, 'r') as file:
# for line in file:
# enriched += line.strip() + "\n"
# file.close()

# postproc = postproc + enriched + "\n}"

# with open(outfile, "w") as file:
# file.write(postproc)
# file.close()



Expand Down

0 comments on commit 3190dbb

Please sign in to comment.