Changes to graph.serialize() by ashleysommer · Pull Request #1183 · RDFLib/rdflib (original) (raw)
This is part of our work to simplify and modernize the methods on rdflib.Graph
to clean up the API surface of the Graph.
These are some long-overdue changes to serialize()
. This is a slightly breaking change, so will be coming as part of RDFLib 6.0.0, but is done in such a way as to minimize breakage as much as possible.
These changes are:
- Change default format from 'xml' to 'turtle'
- If
serialize()
destination=None
andencoding=None
, output is astr
, notbytes
- Add a new convenience method to print the Graph contents (turtle by default)
- eg to print the Graph as trig format:
g.print(format="trig")
Lots of fixes in tests to adapt to these changes (serialize is used a lot to check graph state in tests).
Blacked files which were involved in this change.