Skip to main content

Ordered Turtle Serializer for rdflib

Project description

An extension to the rdflib Turtle serializer that adds order (at the price of speed). Useful when you need to generate diffs between Turtle files, or just to make it easier for human beings to inspect the files.

$ pip install otsrdflib

Usage:

from rdflib import graph
from otsrdflib import OrderedTurtleSerializer

my_graph = Graph()

out = open('out.ttl', 'wb')
serializer = OrderedTurtleSerializer(my_graph)
serializer.serialize(out)

Subjects are grouped by class membership. The order of classes is configured through serializer.topClasses. A default list is provided to have e.g. SKOS.ConceptScheme classes appear before SKOS.Concept:

serializer.topClasses = [SKOS.ConceptScheme,
                       FOAF.Organization,
                       SD.Service,
                       SD.Dataset,
                       SD.Graph,
                       SD.NamedGraph,
                       ISOTHES.ThesaurusArray,
                       SKOS.Concept]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

otsrdflib-0.1.0.tar.gz (2.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page