Skip to content

Commit

Permalink
Merge pull request #364 from emmo-repo/close-file-before-read
Browse files Browse the repository at this point in the history
Close temporary file before reading it
  • Loading branch information
jesper-friis authored Feb 22, 2022
2 parents e920509 + 2ee1aed commit ff951b4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ontopy/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,11 @@ def save(
super().save(file=filename, format=revmap[format], **kwargs)
else:
with tempfile.NamedTemporaryFile(suffix=".owl") as handle:
super().save(file=handle.name, format="rdfxml", **kwargs)
graph = rdflib.Graph()
graph.parse(handle.name, format="xml")
graph.serialize(destination=filename, format=format)
tmpname = handle.name
super().save(file=tmpname, format="rdfxml", **kwargs)
graph = rdflib.Graph()
graph.parse(tmpname, format="xml")
graph.serialize(destination=filename, format=format)

def get_imported_ontologies(self, recursive=False):
"""Return a list with imported ontologies.
Expand Down

0 comments on commit ff951b4

Please sign in to comment.