diff options
author | Tom Gillespie <tgbugs@gmail.com> | 2019-05-16 14:00:46 -0700 |
---|---|---|
committer | Tom Gillespie <tgbugs@gmail.com> | 2019-05-16 14:00:49 -0700 |
commit | 0cc2b106b27ed2963978620100db6ee9505f0961 (patch) | |
tree | 00b8c6d7e1bac4121dd47b8cfabb443c1c7f1f80 | |
parent | 71f4ab46e97ff7f92f41a34590ed651727a212d8 (diff) | |
download | rdflib-0cc2b106b27ed2963978620100db6ee9505f0961.tar.gz |
added a class level option to roundtrip prefixes
This is the simplest way to allow configuration of whether prefixes are
roundtripped during serialization. If someone needs to roundtrip the
prefixes then they can import the serializer into their code and see the
class variable, or if they care enough about the exact way things are
serialized they will likely be subclassing the serializer anyway.
-rw-r--r-- | rdflib/plugins/serializers/turtle.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py index daf9e17d..6752a399 100644 --- a/rdflib/plugins/serializers/turtle.py +++ b/rdflib/plugins/serializers/turtle.py @@ -43,6 +43,7 @@ class RecursiveSerializer(Serializer): predicateOrder = [RDF.type, RDFS.label] maxDepth = 10 indentString = u" " + roundtrip_prefixes = False def __init__(self, store): @@ -110,8 +111,9 @@ class RecursiveSerializer(Serializer): self._subjects = {} self._topLevels = {} - for prefix, ns in self.store.namespaces(): - self.addNamespace(prefix, ns) + if self.roundtrip_prefixes: + for prefix, ns in self.store.namespaces(): + self.addNamespace(prefix, ns) def buildPredicateHash(self, subject): """ |