franz.openrdf.rio package

Submodules

franz.openrdf.rio.formats module

class franz.openrdf.rio.formats.Format(name, mime_types=None, charset='UTF-8', file_extensions=None, register=True)

Bases: object

Represents the concept of a data serialization format. Data formats are identified by a {@link #getName() name} and can have one or more associated MIME types, zero or more associated file extensions and can specify a default character encoding.

This is a base class used by format subclasses for specific types of data, such as triples and tuples

When a subclass of this class is declared all upper case static fields that are dictionaries are converted to class instances. Data in the dictionary is passed as arguments to the constructor.

__init__(name, mime_types=None, charset='UTF-8', file_extensions=None, register=True)

Initialize a new format object.

Parameters:
  • name – Human-readable name of the format.
  • mime_types – A list of MIME types used for this format. The first element of this list will be used as the content-type header during uploads.
  • charset – Character set used by the format.
  • file_extensions – List of file extensions for this format.
  • register – If True file extensions will be added to the map used by Format.format_for_file_name().
classmethod format_for_file_name(filename)

Try to guess appropriate RDF format from a file name. Return a pair (format, compression) where format is an RDF format or None (if no matching format was found) and compression is a supported compression method (currently either None or “gzip”).

Parameters:filename (string) – File path.
Returns:Format (or None) and compression type.
Return type:(RDFFormat|None, string|None)
static mime_type_for_format(output_format)

Get the preferred MIME type for a data format. Raise an error if the format is None. The format can be a string, in which case it is returned as-is.

Parameters:output_format (franz.openrdf.rio.formats.Format|str) – the format to get the MIME type for.
Returns:A MIME type.
Return type:string
classmethod register(fmt)

Register a format object.

class franz.openrdf.rio.formats.FormatMeta(name, bases, dct)

Bases: type

__init__(name, bases, dct)

Initialize self. See help(type(self)) for accurate signature.

franz.openrdf.rio.rdfformat module

class franz.openrdf.rio.rdfformat.RDFFormat(name, mime_types=None, charset='UTF-8', file_extensions=None, supports_namespaces=False, supports_contexts=False, supports_attributes=False, register=True)

Bases: franz.openrdf.rio.formats.Format

Represents the concept of an RDF data serialization format. RDF formats are identified by a name and can have one or more associated MIME types, zero or more associated file extensions and can specify a default character encoding. Some formats are able to encode context information while others are not; this is indicated by the value of supports_contexts field. Similaraly, formats for which the supports_attributes flag is True are capable of encoding triple attributes.

JSONLD = RDFFormat.JSONLD: JSON-LD
NQUADS = RDFFormat.NQUADS: N-Quads
NQX = RDFFormat.NQX: Extended N-Quads (with attributes)
NTRIPLES = RDFFormat.NTRIPLES: N-Triples
RDFXML = RDFFormat.RDFXML: RDF/XML
TABLE = RDFFormat.TABLE: Table
TRIG = RDFFormat.TRIG: TriG
TRIX = RDFFormat.TRIX: TriX
TURTLE = RDFFormat.TURTLE: Turtle
__init__(name, mime_types=None, charset='UTF-8', file_extensions=None, supports_namespaces=False, supports_contexts=False, supports_attributes=False, register=True)

Initialize a new RDF format object.

Parameters:
  • name – Human-readable name of the format.
  • mime_types – A list of MIME types used for this format. The first element of this list will be used as the content-type header during uploads.
  • charset – Character set used by the format.
  • file_extensions – List of file extensions for this format.
  • supports_namespaces – If true, the format supports namespaces and qualified names. This has no impact on the Python API.
  • supports_contexts – If True the format can store quads (and not just triples).
  • supports_attributes – If True the format can represent triple attributes.
  • register – If True file extensions will be added to the map used by Format.format_for_file_name().

franz.openrdf.rio.rdfwriter module

class franz.openrdf.rio.rdfwriter.NTriplesWriter(filePath=None)

Bases: franz.openrdf.rio.rdfwriter.RDFWriter

Records the format as NTriples, and records the ‘filePath’ where the serialized RDF will be output to. If ‘filePath’ is None, output is to standard output.

TODO: THERE IS A WRITER PROTOCOL IMPLEMENTED IN RDFXMLWriter THAT ISN’T IMPLEMENTED HERE. CONSIDER ADDING IT (OR NOT).

__init__(filePath=None)

Initialize self. See help(type(self)) for accurate signature.

class franz.openrdf.rio.rdfwriter.RDFWriter(rdfFormat, filePath=None)

Bases: object

__init__(rdfFormat, filePath=None)

Initialize self. See help(type(self)) for accurate signature.

getFilePath()
getRDFFormat()

franz.openrdf.rio.rdfxmlwriter module

class franz.openrdf.rio.rdfxmlwriter.RDFXMLWriter(filePath=None)

Bases: franz.openrdf.rio.rdfwriter.RDFWriter

An implementation of the RDFWriter interface that writes RDF documents in XML-serialized RDF format. This records the format as RDF/XML, and records the ‘filePath’ where the serialized RDF will be output to. If ‘filePath’ is None, output is to standard output.

__init__(filePath=None)

Initialize self. See help(type(self)) for accurate signature.

franz.openrdf.rio.tupleformat module

class franz.openrdf.rio.tupleformat.TupleFormat(name, mime_types=None, charset='UTF-8', file_extensions=None, register=True)

Bases: franz.openrdf.rio.formats.Format

Serialization formats for tuples returned by queries. See Format.

CSV = TupleFormat.CSV: SPARQL CSV
JSON = TupleFormat.JSON: SPARQL JSON
SPARQL = TupleFormat.SPARQL: SPARQL XML
TABLE = TupleFormat.TABLE: Table
TSV = TupleFormat.TSV: SPARQL TSV

Module contents