prov.serializers package¶
Module contents¶
prov.serializers.provjson module¶
-
class
prov.serializers.provjson.ProvJSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]¶ Bases:
json.decoder.JSONDecoder
-
class
prov.serializers.provjson.ProvJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ Bases:
json.encoder.JSONEncoder-
default(o)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
-
exception
prov.serializers.provjson.ProvJSONException[source]¶ Bases:
prov.Error
-
class
prov.serializers.provjson.ProvJSONSerializer(document=None)[source]¶ Bases:
prov.serializers.SerializerPROV-JSON serializer for
ProvDocument-
deserialize(stream, **kwargs)[source]¶ Deserialize from the PROV JSON representation to a
ProvDocumentinstance.Parameters: stream – Input data.
-
serialize(stream, **kwargs)[source]¶ Serializes a
ProvDocumentinstance to PROV-JSON.Parameters: stream – Where to save the output.
-
prov.serializers.provn module¶
-
class
prov.serializers.provn.ProvNSerializer(document=None)[source]¶ Bases:
prov.serializers.SerializerPROV-N serializer for ProvDocument
-
deserialize(stream, **kwargs)[source]¶ Abstract method for deserializing.
Parameters: stream – Stream object to deserialize the document from.
-
serialize(stream, **kwargs)[source]¶ Serializes a
prov.model.ProvDocumentinstance to a PROV-N.Parameters: stream – Where to save the output.
-
prov.serializers.provrdf module¶
PROV-RDF serializers for ProvDocument
-
exception
prov.serializers.provrdf.ProvRDFException[source]¶ Bases:
prov.Error
-
class
prov.serializers.provrdf.ProvRDFSerializer(document=None)[source]¶ Bases:
prov.serializers.SerializerPROV-O serializer for
ProvDocument-
deserialize(stream, rdf_format='trig', **kwargs)[source]¶ Deserialize from the PROV-O representation to a
ProvDocumentinstance.Parameters: - stream – Input data.
- rdf_format – The RDF format of the input data, default: TRiG.
-
serialize(stream=None, rdf_format='trig', **kwargs)[source]¶ Serializes a
ProvDocumentinstance to PROV-O.Parameters: - stream – Where to save the output.
- rdf_format – The RDF format of the output, default to TRiG.
-
-
prov.serializers.provrdf.walk(children, level=0, path=None, usename=True)[source]¶ Generate all the full paths in a tree, as a dict.
Example: >>> from prov.serializers.provrdf import walk >>> iterables = [('a', lambda: [1, 2]), ('b', lambda: [3, 4])] >>> [val['a'] for val in walk(iterables)] [1, 1, 2, 2] >>> [val['b'] for val in walk(iterables)] [3, 4, 3, 4]
prov.serializers.provxml module¶
-
exception
prov.serializers.provxml.ProvXMLException[source]¶ Bases:
prov.Error
-
class
prov.serializers.provxml.ProvXMLSerializer(document=None)[source]¶ Bases:
prov.serializers.SerializerPROV-XML serializer for
ProvDocument-
deserialize(stream, **kwargs)[source]¶ Deserialize from PROV-XML representation to a
ProvDocumentinstance.Parameters: stream – Input data.
-
deserialize_subtree(xml_doc, bundle)[source]¶ Deserialize an etree element containing a PROV document or a bundle and write it to the provided internal object.
Parameters: - xml_doc – An etree element containing the information to read.
- bundle – The bundle object to write to.
-
serialize(stream, force_types=False, **kwargs)[source]¶ Serializes a
ProvDocumentinstance to PROV-XML.Parameters: - stream – Where to save the output.
- force_types (boolean, optional) – Will force xsd:types to be written for most attributes mainly PROV-“attributes”, e.g. tags not in the PROV namespace. Off by default meaning xsd:type attributes will only be set for prov:type, prov:location, and prov:value as is done in the official PROV-XML specification. Furthermore the types will always be set if the Python type requires it. False is a good default and it should rarely require changing.
-
serialize_bundle(bundle, element=None, force_types=False)[source]¶ Serializes a bundle or document to PROV XML.
Parameters: - bundle – The bundle or document.
- element – The XML element to write to. Will be created if None.
- force_types (boolean, optional) – Will force xsd:types to be written for most attributes mainly PROV-“attributes”, e.g. tags not in the PROV namespace. Off by default meaning xsd:type attributes will only be set for prov:type, prov:location, and prov:value as is done in the official PROV-XML specification. Furthermore the types will always be set if the Python type requires it. False is a good default and it should rarely require changing.
-