Skip to content

Commit

Permalink
refactor: move license maps to maps.py
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Feb 9, 2024
1 parent 32e34c3 commit 5e23626
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
19 changes: 18 additions & 1 deletion migrate/maps.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 1 addition & 14 deletions migrate/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5e23626

Please sign in to comment.