# prov.serializers package

## Module contents

`prov.serializers.``get`(format_name)

  Returns the serializer class for the specified format. Raises a DoNotExist

## prov.serializers.provjson module

class `prov.serializers.provjson.``ProvJSONSerializer`(document=None)

  Bases: `prov.serializers.Serializer`

  PROV-JSON serializer for `ProvDocument`

  `deserialize`(stream, **kwargs)

    Deserialize from the PROV JSON representation to a `ProvDocument` instance.

    Parameters: | stream – Input data.

  `serialize`(stream, **kwargs)

    Serializes a `ProvDocument` instance to PROV-JSON.

    Parameters: | stream – Where to save the output.

## prov.serializers.provn module

class `prov.serializers.provn.``ProvNSerializer`(document=None)

  Bases: `prov.serializers.Serializer`

  PROV-N serializer for ProvDocument

  `serialize`(stream, **kwargs)

    Serializes a `prov.model.ProvDocument` instance to a PROV-N.

    Parameters: | stream – Where to save the output.

## prov.serializers.provrdf module

PROV-RDF serializers for ProvDocument

class `prov.serializers.provrdf.``ProvRDFSerializer`(document=None)

  Bases: `prov.serializers.Serializer`

  PROV-O serializer for `ProvDocument`

  `deserialize`(stream, rdf_format='trig', **kwargs)

    Deserialize from the Prov-O representation to a `ProvDocument` instance.

    Parameters: | stream – Input data.

  `serialize`(stream=None, rdf_format='trig', **kwargs)

    Serializes a `ProvDocument` instance to Prov-O.

    Parameters: | stream – Where to save the output.

`prov.serializers.provrdf.``walk`(children, level=0, path=None, usename=True)

  Generate all the full paths in a tree, as a dict.

      >>> from nipype.pipeline.engine.utils 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

class `prov.serializers.provxml.``ProvXMLSerializer`(document=None)

  Bases: `prov.serializers.Serializer`

  PROV-XML serializer for `ProvDocument`

  `deserialize`(stream, **kwargs)

    Deserialize from PROV-XML representation to a `ProvDocument` instance.

    Parameters: | stream – Input data.

  `deserialize_subtree`(xml_doc, bundle)

    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)

    Serializes a `ProvDocument` instance 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)

    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.