From 48ac7ecd159870eca05bf4d2c9ea2c1592a600ae Mon Sep 17 00:00:00 2001 From: Sylvain Gouttebroze Date: Wed, 1 Dec 2021 15:54:25 +0100 Subject: [PATCH 1/2] fix #313 modification of owl temporary file in save function --- ontopy/ontology.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index dc24614fc..708269174 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -604,11 +604,12 @@ def save( revmap = {value: key for key, value in FMAP.items()} 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) + fileTemp = os.path.join(tempfile.gettempdir(), os.urandom(24).hex()) + super().save(fileTemp, format="rdfxml", **kwargs) + graph = rdflib.Graph() + print(fileTemp) + graph.parse(fileTemp, format="xml") + graph.serialize(destination=filename, format=format) def get_imported_ontologies(self, recursive=False): """Return a list with imported ontologies. From 01e4470765b590e7d9015369f64358d482a939e3 Mon Sep 17 00:00:00 2001 From: Sylvain Gouttebroze <39990946+sygout@users.noreply.github.com> Date: Wed, 1 Dec 2021 21:28:47 +0100 Subject: [PATCH 2/2] remove print in ontopy/ontology.py Co-authored-by: Francesca L. Bleken <48128015+francescalb@users.noreply.github.com> --- ontopy/ontology.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index 708269174..491afbe47 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -607,7 +607,6 @@ def save( fileTemp = os.path.join(tempfile.gettempdir(), os.urandom(24).hex()) super().save(fileTemp, format="rdfxml", **kwargs) graph = rdflib.Graph() - print(fileTemp) graph.parse(fileTemp, format="xml") graph.serialize(destination=filename, format=format)