longturtle
LongTurtle RDF graph serializer for RDFLib. See http://www.w3.org/TeamSubmission/turtle/ for syntax specification.
This variant, longturtle as opposed to just turtle, makes some small format changes to turtle - the original turtle serializer. It:
- uses PREFIX instead of @prefix
- uses BASE instead of @base
- adds a new line at RDF.type, or ‘a’
- adds a newline and an indent for all triples with more than one object (object list)
- adds a new line and ‘;’ for the last triple in a set with ‘.’ on the start of the next line
-
uses default encoding (encode()) is used instead of “latin-1”
-
Nicholas Car, 2023
Classes:
-
LongTurtleSerializer–LongTurtle, a Turtle serialization format.
LongTurtleSerializer
Bases: RecursiveSerializer
LongTurtle, a Turtle serialization format.
When the optional parameter canon is set to True, the graph is canonicalized
before serialization. This normalizes blank node identifiers and allows for
deterministic serialization of the graph. Useful when consistent outputs are required.
Methods:
-
addNamespace– -
canonize–Apply canonicalization to the store.
-
doList– -
endDocument– -
getQName– -
get_pname– -
isValidList–Checks if l is a valid RDF list, i.e. no nodes have other properties,
-
label– -
objectList– -
p_default– -
p_squared– -
path– -
predicateList– -
preprocessTriple– -
reset– -
s_default– -
s_squared– -
serialize– -
startDocument– -
statement– -
verb–
Attributes:
-
indentString– -
keywords– -
short_name– -
stream–
Source code in rdflib/plugins/serializers/longturtle.py
addNamespace
Source code in rdflib/plugins/serializers/longturtle.py
canonize
Apply canonicalization to the store.
This normalizes blank node identifiers and allows for deterministic serialization of the graph.
Source code in rdflib/plugins/serializers/longturtle.py
doList
Source code in rdflib/plugins/serializers/longturtle.py
endDocument
getQName
Source code in rdflib/plugins/serializers/longturtle.py
get_pname
Source code in rdflib/plugins/serializers/longturtle.py
isValidList
Checks if l is a valid RDF list, i.e. no nodes have other properties, and no node in the list (including the head) is the object of more than one statement.
The second condition matters because ( … ) collection syntax
inlines the whole chain at a single reference: if some other
statement also points at one of the list’s cells, that statement
would be left referring to a node that the inline form never writes
out on its own, and the serialization would not round-trip.
Source code in rdflib/plugins/serializers/longturtle.py
label
Source code in rdflib/plugins/serializers/longturtle.py
objectList
Source code in rdflib/plugins/serializers/longturtle.py
p_default
p_squared
Source code in rdflib/plugins/serializers/longturtle.py
path
predicateList
Source code in rdflib/plugins/serializers/longturtle.py
preprocessTriple
Source code in rdflib/plugins/serializers/longturtle.py
reset
s_default
s_squared
Source code in rdflib/plugins/serializers/longturtle.py
serialize
serialize(stream: IO[bytes], base: Optional[str] = None, encoding: Optional[str] = None, spacious: Optional[bool] = None, **kwargs: Any) -> None