Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata_dictionary/cff.py
Show All 19 Lines | |||||
class CffMapping(YamlMapping): | class CffMapping(YamlMapping): | ||||
"""Dedicated class for Citation (CITATION.cff) mapping and translation""" | """Dedicated class for Citation (CITATION.cff) mapping and translation""" | ||||
name = "cff" | name = "cff" | ||||
filename = b"CITATION.cff" | filename = b"CITATION.cff" | ||||
mapping = CROSSWALK_TABLE["Citation File Format Core (CFF-Core) 1.0.2"] | mapping = CROSSWALK_TABLE["Citation File Format Core (CFF-Core) 1.0.2"] | ||||
string_fields = ["keywords", "license", "abstract", "version", "doi"] | string_fields = ["keywords", "license", "abstract", "version", "doi"] | ||||
date_fields = ["date-released"] | |||||
uri_fields = ["repository-code"] | uri_fields = ["repository-code"] | ||||
def _translate_author(self, graph: Graph, author: dict) -> rdflib.term.Node: | def _translate_author(self, graph: Graph, author: dict) -> rdflib.term.Node: | ||||
node: rdflib.term.Node | node: rdflib.term.Node | ||||
if "orcid" in author and isinstance(author["orcid"], str): | if "orcid" in author and isinstance(author["orcid"], str): | ||||
node = URIRef(author["orcid"]) | node = URIRef(author["orcid"]) | ||||
else: | else: | ||||
node = BNode() | node = BNode() | ||||
Show All 16 Lines | class CffMapping(YamlMapping): | ||||
def normalize_doi(self, s: str) -> URIRef: | def normalize_doi(self, s: str) -> URIRef: | ||||
if isinstance(s, str): | if isinstance(s, str): | ||||
return DOI + s | return DOI + s | ||||
def normalize_license(self, s: str) -> URIRef: | def normalize_license(self, s: str) -> URIRef: | ||||
if isinstance(s, str): | if isinstance(s, str): | ||||
return SPDX + s | return SPDX + s | ||||
def normalize_date_released(self, s: str) -> Literal: | |||||
if isinstance(s, str): | |||||
return Literal(s, datatype=SCHEMA.Date) |