provdbconnector.utils package

Submodules

provdbconnector.utils.converter module

provdbconnector.utils.converter.form_string(content)[source]

Take a string or BufferedReader as argument and transform the string into a ProvDocument

Parameters:content – Takes a sting or BufferedReader
Returns:ProvDocument
provdbconnector.utils.converter.to_json(document=None)[source]

Try to convert a ProvDocument into the json representation

Parameters:document (prov.model.ProvDocument) –
Returns:Json string of the document
Return type:str
provdbconnector.utils.converter.from_json(json=None)[source]

Try to convert a json string into a document

Parameters:json (str) – The json str
Returns:Prov Document
Return type:prov.model.ProvDocument
Raise:NoDocumentException
provdbconnector.utils.converter.to_provn(document=None)[source]

Try to convert a document into a provn representation

Parameters:document (prov.model.ProvDocument) – Prov document to convert
Returns:The prov-n str
Return type:str
Raise:NoDocumentException
provdbconnector.utils.converter.from_provn(provn_str=None)[source]

Try to convert a provn string into a ProvDocument

Parameters:provn_str (str) – The string to convert
Returns:The Prov document
Return type:ProvDocument
Raises:NoDocumentException
provdbconnector.utils.converter.to_xml(document=None)[source]

Try to convert a document into an xml string

Parameters:
  • document – The ProvDocument to convert
  • document – ProvDocument
Returns:

The xml string

Return type:

str

provdbconnector.utils.converter.from_xml(xml_str=None)[source]

Try to convert a xml string into a ProvDocument

Parameters:xml_str (str) – The xml string
Returns:The Prov document
Return type:ProvDocument

provdbconnector.utils.serializer module

provdbconnector.utils.serializer.FormalAndOtherAttributes

alias of provdbconnector.utils.serializer.formal_and_other_attributes

provdbconnector.utils.serializer.encode_dict_values_to_primitive(dict_values)[source]

This function transforms a dict with all kind of types into a dict with only

  • str
  • dict
  • book
  • str

values

Parameters:dict_values
Returns:
provdbconnector.utils.serializer.encode_string_value_to_primitive(value)[source]

Convert a value into one of the following types:

  • dict
  • str
  • float
  • int
  • list
Parameters:value
Returns:
provdbconnector.utils.serializer.literal_json_representation(literal)[source]

Some internationalization stuff

Parameters:literal
Returns:
provdbconnector.utils.serializer.encode_json_representation(value)[source]

Get the type of a value

Parameters:value
Returns:
provdbconnector.utils.serializer.add_namespaces_to_bundle(prov_bundle, metadata)[source]

Add all namespaces in the metadata_dict to the provided bundle

Parameters:
  • prov_bundle
  • metadata
Returns:

None

provdbconnector.utils.serializer.create_prov_record(bundle, prov_type, prov_id, properties, type_map)[source]
Parameters:
  • bundle
  • prov_type – valid prov type like prov:Entry as string
  • prov_id – valid id as string like <namespace>:<name>
  • properties – dict{attr_name:attr_value} dict with all properties (prov and additional)
  • type_map – dict{attr_name:type_str} Contains the type information for each property (only if type is necessary)
Returns:

ProvRecord

provdbconnector.utils.serializer.decode_json_representation(value, type, bundle)[source]

Return the value based on the type see also encode_json_representation

Parameters:
  • value
  • type
  • bundle
Returns:

provdbconnector.utils.serializer.split_into_formal_and_other_attributes(attributes, metadata)[source]

This function split the attributes and metadata into formal attributes and other attributes. Helpful for merge operations and searching for duplicate relations

Parameters:
  • attributes
  • metadata
Returns:

namedtuple(formal_attributes, other_attributes)

Return type:

FormalAndOtherAttributes

provdbconnector.utils.serializer.merge_record(attributes, metadata, other_attributes, other_metadata)[source]

Merge 2 records into one

Parameters:
  • attributes – The original attributes
  • metadata – The original metadata
  • other_attributes – The attributes to merge
  • other_metadata – The metadata to merge
Returns:

tuple(attributes, metadata)

Return type:

Tuple(attributes,metadata)

provdbconnector.utils.serializer.serialize_namespace(namespace: prov.identifier.Namespace)[source]

provdbconnector.utils.validator module

class provdbconnector.utils.validator.Validator[source]

Bases: object

Class to do some validation, not implemented yet

Module contents