From cabdadc19e1369ee458be98e70e6b8e5ed69562f Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Thu, 12 Sep 2024 12:55:14 +0200 Subject: [PATCH] Escape n3 triples to deal with multiline issues --- src/omero_rdf/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/omero_rdf/__init__.py b/src/omero_rdf/__init__.py index a788716..f855b00 100644 --- a/src/omero_rdf/__init__.py +++ b/src/omero_rdf/__init__.py @@ -223,7 +223,8 @@ def emit(self, triple: Triple): else: # Streaming s, p, o = triple - print(f"""{s.n3()}\t{p.n3()}\t{o.n3()} .""") + escaped = o.n3().encode("unicode_escape").decode("utf-8") + print(f"""{s.n3()}\t{p.n3()}\t{escaped} .""") def close(self): if self.pretty_print: @@ -376,7 +377,7 @@ def descend( """ if isinstance(target, list): - return([self.descend(gateway, t, handler) for t in target]) + return [self.descend(gateway, t, handler) for t in target] elif isinstance(target, Screen): scr = self._lookup(gateway, "Screen", target.id)