facile_rs.utils.metadata.zenodo

Module Contents

Classes

ZenodoMetadata

Data

logger

API

logger = 'getLogger(...)'
class ZenodoMetadata(data={})

Initialization

Initialize the ZenodoMetadata object from CodeMeta metadata.

Parameters:

data (dict) – CodeMeta metadata, typically the data attribute of a CodemetaMetadata instance.

prefixes = None
ZENODO_CONTRIBUTORTYPES = ['contactperson', 'datacollector', 'datacurator', 'datamanager', 'distributor', 'editor', 'hostingin...
ZENODO_RELATIONSHIPS = ['iscitedby', 'cites', 'issupplementto', 'issupplementedby', 'iscontinuedby', 'continues', 'isdescri...
get_license_id_from_spdx(spdx_id)

Get Zenodo license ID from SPDX identifier. Return None if the id could not be validated.

Parameters:

spdx_id – SPDX license identifier

Returns:

Zenodo identifier for the license or None if not found

to_rights(license)

Convert a CodeMeta license to a Zenodo rights object.

Parameters:

license (str or dict) – CodeMeta license, URL or Schema.org CreativeWork object

Returns:

Zenodo rights object

Return type:

dict

to_person_or_org(value, contributorType=None)

Converts a Person or Organization object to a Zenodo “person_or_org”. If contributorType is not None, it will be converted to a Zenodo “contributor_person_or_org”.

Parameters:
  • value (dict) – CodeMeta Person or Organization object

  • contributorType (None or str) – None or type of contributor, taken from the Zenodo controlled vocabulary defined in self.ZENODO_CONTRIBUTORTYPES

Returns:

Zenodo person_or_org or contributor_person_or_org object

Return type:

dict

validate_funding_identifier(funding_identifier)

Validate a funding identifier against the Zenodo API. If funding could be validated, return the funding object, otherwise return an empty dictionary.

Parameters:

funding_identifier (str) – funding identifier to validate

Returns:

Zenodo funding object or empty dictionary

Return type:

dict

to_funding(funding)

Convert a CodeMeta funding object to a Zenodo funding object.

Parameters:

funding (dict or str) – CodeMeta funding object

Returns:

Zenodo funding object

validate_funder_identifier(funder_identifier)

Validate a funder identifier against the Zenodo API. If funder could be validated, return the funder identifier, otherwise return None. Suuports plain identifier or full ROR URL.

to_funder(funder)

Convert a CodeMeta funder to a Zenodo funder object.

Convert an identifier to a Zenodo related identifier object.

Parameters:
  • identifier (str) – Persistent identifier of related publication or dataset. Supported identifier schemes: ARK, arXiv, Bibcode, DOI, EAN13, EISSN, Handle, IGSN, ISBN, ISSN, ISTC, LISSN, LSID, PubMed ID, PURL, UPC, URL, URN, W3ID.

  • relation (str) – relationship described with controlled vocabulary defined in self.ZENODO_RELATIONSHIPS

Returns:

Zenodo related identifier object

Return type:

dict or None

to_subjects(keywords)

Convert CodeMeta keywords to Zenodo subjects.

add_to_array_field(zenodo_dict, key, value)

Add an object to a field of type “array” in a Zenodo metadata dictionary. Add the field if it doesn’t exist yet, append the value to the field otherwise. Does nothing if value is None.

Parameters:
  • zenodo_dict – Zenodo metadata dictionary; will be modified in place

  • key – key to be added or updated

  • value – value to be added. If None, the function does nothing.

as_dict()

Prepare Zenodo payload to be passed to the Zenodo API.

Returns:

Zenodo metadata dictionary