From 5e23626c714a4a9dc4f79d6b266d3f3c3a2c1ba5 Mon Sep 17 00:00:00 2001 From: phette23 Date: Fri, 9 Feb 2024 15:01:54 -0800 Subject: [PATCH] refactor: move license maps to maps.py --- migrate/maps.py | 19 ++++++++++++++++++- migrate/record.py | 15 +-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/migrate/maps.py b/migrate/maps.py index 14f4c52..d57fab6 100644 --- a/migrate/maps.py +++ b/migrate/maps.py @@ -1,4 +1,21 @@ -# Maps: simple dict maps of values from MODS metadata to InvenioRDM +###################################################### +# Maps # +# simple dict maps from MODS metadata to InvenioRDM # +###################################################### + +# CCA/C Archives uses CC-BY-NC4.0 in mods/accessCondition +# There are a few other CC licenses used +license_href_map: dict[str, str] = { + "http://rightsstatements.org/vocab/InC/1.0/": "copyright", + "https://creativecommons.org/licenses/by-nc/4.0/": "cc-by-nc-4.0", +} + +license_text_map: dict[str, str] = { + "CC BY 4.0": "cc-by-4.0", + "CC BY-NC-ND 4.0": "cc-by-nc-nd-4.0", + "CC BY-NC-SA 4.0": "cc-by-nc-sa-4.0", + "https://creativecommons.org/licenses/by-nc/4.0/": "cc-by-nc-4.0", +} # mods typeOfResource => our Invenio resource types # Our subset of the full list of Invenio resource types: bachelors-thesis, publication, event, image, publication-article, masters-thesis, other, video (Video/Audio) diff --git a/migrate/record.py b/migrate/record.py index 3aa9598..964481d 100644 --- a/migrate/record.py +++ b/migrate/record.py @@ -15,7 +15,7 @@ import xmltodict from names import parse_name -from maps import resource_type_map, role_map +from maps import * from utils import find_items, mklist, to_edtf @@ -350,21 +350,8 @@ def resource_type(self) -> dict[str, str]: @property def rights(self) -> List[dict[str, str | dict[str, str]]]: - # TODO add maps to maps.py # https://inveniordm.docs.cern.ch/reference/metadata/#rights-licenses-0-n # ! returned id values MUST be IDs from licenses.csv in cca/cca_invenio - # CCA/C Archives uses CC-BY-NC4.0 in mods/accessCondition - # There are a few other CC licenses used - license_href_map: dict[str, str] = { - "http://rightsstatements.org/vocab/InC/1.0/": "copyright", - "https://creativecommons.org/licenses/by-nc/4.0/": "cc-by-nc-4.0", - } - license_text_map: dict[str, str] = { - "CC BY 4.0": "cc-by-4.0", - "CC BY-NC-ND 4.0": "cc-by-nc-nd-4.0", - "CC BY-NC-SA 4.0": "cc-by-nc-sa-4.0", - "https://creativecommons.org/licenses/by-nc/4.0/": "cc-by-nc-4.0", - } # We always have exactly one accessCondition node, str or dict accessCondition = self.xml.get("mods", {}).get("accessCondition", "") if type(accessCondition) == dict: