fairdm.core.project.transforms#

Metadata export for the Project model.

:class:ProjectDataCiteTransform maps a project to DataCite’s JSON form and :class:ProjectSchemaOrgTransform to schema.org JSON-LD. The module-level :func:to_datacite and :func:to_json_ld wrap them for the administrative actions.

Module Contents#

Classes#

ProjectDataCiteTransform

Map a project to DataCite’s JSON metadata form.

ProjectSchemaOrgTransform

Map a project to schema.org JSON-LD.

Functions#

to_datacite

Map a project to DataCite’s JSON metadata form.

to_json_ld

Map a project to schema.org JSON-LD.

API#

class ProjectDataCiteTransform#

Bases: fairdm.contrib.contributors.utils.transforms.BaseTransform

Map a project to DataCite’s JSON metadata form.

BaseTransform.export() is typed on Contributor, and generalising it is out of scope (#176), so this override narrows the parameter type instead.

export(project) → dict#

Map a project to DataCite’s JSON metadata form.

Carries the project’s name plus its descriptions, dates, identifiers, contributions and funding. Absent optional metadata is omitted rather than emitted as an empty structure.

Args: project: The project to export.

Returns: The DataCite metadata dictionary.

class ProjectSchemaOrgTransform#

Bases: fairdm.contrib.contributors.utils.transforms.BaseTransform

Map a project to schema.org JSON-LD.

BaseTransform.export() is typed on Contributor, and generalising it is out of scope (#176), so this override narrows the parameter type instead.

export(project) → dict#

Map a project to schema.org JSON-LD, carrying an explicit context.

The email key is dropped from each contributor here. The contributor transform is shared with callers who need the address, so it is removed at the export boundary.

Args: project: The project to export.

Returns: The JSON-LD dictionary.

to_datacite(project) → dict#

Map a project to DataCite’s JSON metadata form.

Args: project: The project to export.

Returns: The DataCite metadata dictionary.

to_json_ld(project) → dict#

Map a project to schema.org JSON-LD.

Args: project: The project to export.

Returns: The JSON-LD dictionary.