commonmeta-py 0.31__py3-none-any.whl → 0.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commonmeta/__init__.py +1 -1
- commonmeta/constants.py +27 -0
- commonmeta/utils.py +13 -0
- commonmeta/writers/inveniordm_writer.py +40 -15
- {commonmeta_py-0.31.dist-info → commonmeta_py-0.32.dist-info}/METADATA +1 -1
- {commonmeta_py-0.31.dist-info → commonmeta_py-0.32.dist-info}/RECORD +9 -9
- {commonmeta_py-0.31.dist-info → commonmeta_py-0.32.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.31.dist-info → commonmeta_py-0.32.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.31.dist-info → commonmeta_py-0.32.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/constants.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
"""Constants for commonmeta-py"""
|
2
|
+
|
2
3
|
from typing import Optional, TypedDict, List
|
3
4
|
|
4
5
|
|
@@ -585,3 +586,29 @@ COMMONMETA_CONTRIBUTOR_ROLES = [
|
|
585
586
|
"Maintainer",
|
586
587
|
"Other",
|
587
588
|
]
|
589
|
+
|
590
|
+
INVENIORDM_IDENTIFIER_TYPES = {
|
591
|
+
"Ark": "ark",
|
592
|
+
"ArXiv": "arxiv",
|
593
|
+
"Bibcode": "ads",
|
594
|
+
"CrossrefFunderID": "crossreffunderid",
|
595
|
+
"DOI": "doi",
|
596
|
+
"EAN13": "ean13",
|
597
|
+
"EISSN": "eissn",
|
598
|
+
"GRID": "grid",
|
599
|
+
"Handle": "handle",
|
600
|
+
"IGSN": "igsn",
|
601
|
+
"ISBN": "isbn",
|
602
|
+
"ISNI": "isni",
|
603
|
+
"ISSN": "issn",
|
604
|
+
"ISTC": "istc",
|
605
|
+
"LISSN": "lissn",
|
606
|
+
"LSID": "lsid",
|
607
|
+
"PMID": "pmid",
|
608
|
+
"PURL": "purl",
|
609
|
+
"UPC": "upc",
|
610
|
+
"URL": "url",
|
611
|
+
"URN": "urn",
|
612
|
+
"W3ID": "w3id",
|
613
|
+
"Other": "other",
|
614
|
+
}
|
commonmeta/utils.py
CHANGED
@@ -1106,3 +1106,16 @@ def timer_func(func):
|
|
1106
1106
|
return value
|
1107
1107
|
|
1108
1108
|
return function_timer
|
1109
|
+
|
1110
|
+
|
1111
|
+
def id_from_url(url: Optional[str]) -> Optional[str]:
|
1112
|
+
"""Return a ID from a URL"""
|
1113
|
+
if url is None:
|
1114
|
+
return None
|
1115
|
+
|
1116
|
+
f = furl(url)
|
1117
|
+
# check for allowed scheme if string is a URL
|
1118
|
+
if f.host is not None and f.scheme not in ["http", "https", "ftp"]:
|
1119
|
+
return None
|
1120
|
+
|
1121
|
+
return str(f.path).strip("/")
|
@@ -1,12 +1,13 @@
|
|
1
1
|
"""InvenioRDM writer for commonmeta-py"""
|
2
2
|
|
3
3
|
import orjson as json
|
4
|
+
from typing import Optional
|
4
5
|
|
5
6
|
from ..base_utils import compact, wrap, parse_attributes
|
6
7
|
from ..date_utils import get_iso8601_date
|
7
8
|
from ..doi_utils import doi_from_url
|
8
|
-
from ..constants import CM_TO_INVENIORDM_TRANSLATIONS
|
9
|
-
from ..utils import get_language, validate_orcid
|
9
|
+
from ..constants import CM_TO_INVENIORDM_TRANSLATIONS, INVENIORDM_IDENTIFIER_TYPES
|
10
|
+
from ..utils import get_language, validate_orcid, id_from_url
|
10
11
|
|
11
12
|
|
12
13
|
def write_inveniordm(metadata):
|
@@ -22,7 +23,9 @@ def write_inveniordm(metadata):
|
|
22
23
|
identifiers = [
|
23
24
|
{
|
24
25
|
"identifier": i.get("identifier", None),
|
25
|
-
"scheme":
|
26
|
+
"scheme": INVENIORDM_IDENTIFIER_TYPES.get(
|
27
|
+
i.get("identifierType", None), "other"
|
28
|
+
),
|
26
29
|
}
|
27
30
|
for i in wrap(metadata.identifiers)
|
28
31
|
if i.get("id", None) != metadata.id
|
@@ -114,18 +117,20 @@ def to_inveniordm_creator(creator: dict) -> dict:
|
|
114
117
|
elif creator.get("name", None):
|
115
118
|
name = creator.get("name", None)
|
116
119
|
|
117
|
-
return
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
return compact(
|
121
|
+
{
|
122
|
+
"person_or_org": compact(
|
123
|
+
{
|
124
|
+
"name": name,
|
125
|
+
"given_name": creator.get("givenName", None),
|
126
|
+
"family_name": creator.get("familyName", None),
|
127
|
+
"type": _type.lower() + "al" if _type else None,
|
128
|
+
"identifiers": format_identifier(creator.get("id", None)),
|
129
|
+
}
|
130
|
+
),
|
131
|
+
"affiliations": to_inveniordm_affiliations(creator),
|
132
|
+
}
|
133
|
+
)
|
129
134
|
|
130
135
|
|
131
136
|
def to_inveniordm_subject(subject: dict) -> dict:
|
@@ -136,3 +141,23 @@ def to_inveniordm_subject(subject: dict) -> dict:
|
|
136
141
|
"subject": subject.get("subject", None),
|
137
142
|
}
|
138
143
|
)
|
144
|
+
|
145
|
+
|
146
|
+
def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
|
147
|
+
"""Convert affiliations to inveniordm affiliations.
|
148
|
+
Returns None if creator is not a person."""
|
149
|
+
|
150
|
+
def format_affiliation(affiliation):
|
151
|
+
return compact(
|
152
|
+
{
|
153
|
+
"id": id_from_url(affiliation.get("id", None)),
|
154
|
+
"name": affiliation.get("name", None),
|
155
|
+
}
|
156
|
+
)
|
157
|
+
|
158
|
+
if creator.get("type", None) != "Person":
|
159
|
+
return None
|
160
|
+
|
161
|
+
return compact(
|
162
|
+
[format_affiliation(i) for i in wrap(creator.get("affiliations", None))]
|
163
|
+
)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=39W6oIc0av4brPAFRuXXJ5wLX43-XDRtrl6X1evn1Oc,1779
|
2
2
|
commonmeta/api_utils.py,sha256=-ZHGVZZhJqnjnsLtp4-PoeHYbDqL0cQme7W70BEjo4U,2677
|
3
3
|
commonmeta/author_utils.py,sha256=zBIPTgP5n7Zx57xomJ2h7x0dvC0AV8gJ2gPoYeDy5Lo,8348
|
4
4
|
commonmeta/base_utils.py,sha256=0t6fr9XGeeTBoMlKSAMI7p_EmKsA6wYRW0roEBXVcc8,3722
|
5
5
|
commonmeta/cli.py,sha256=0IJF1SQ1sKPg7M0Gb8fpX2nBps-G0L13o01__M6c5Z0,6104
|
6
|
-
commonmeta/constants.py,sha256=
|
6
|
+
commonmeta/constants.py,sha256=fB2oMjnPYCJG3Zx6080u0R0ujmXkPRLGSgYOulWyOFw,16411
|
7
7
|
commonmeta/crossref_utils.py,sha256=uffkjbs3732yCzD7hEA5lZ9ZZ648Mftl_n0GGcnEPHc,21918
|
8
8
|
commonmeta/date_utils.py,sha256=amF3E0ZJlh8yY5eY3aVXQyAO1x2WuZHJXw-ajOEcdUQ,5808
|
9
9
|
commonmeta/doi_utils.py,sha256=Dt6K9ADD2ga2WNsOzfX9f29gnubhn7xqeKL7U5pEpBs,8209
|
@@ -57,7 +57,7 @@ commonmeta/resources/styles/modern-language-association.csl,sha256=HI2iU4krze1aH
|
|
57
57
|
commonmeta/resources/styles/vancouver.csl,sha256=lun3_i2oTilgsANk4LjFao2UDPQlGj_hgFgKAWC_DF8,12878
|
58
58
|
commonmeta/schema_utils.py,sha256=Ep8suJgqtgDAvbjVkQxwzAY1MqwwqPwNRKDTMAxMQTg,915
|
59
59
|
commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
|
60
|
-
commonmeta/utils.py,sha256=
|
60
|
+
commonmeta/utils.py,sha256=3OX4BfOkDTkHye4-xpGoTfMrPMvN-02FdS_IBOfoRvw,39796
|
61
61
|
commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45qI,45
|
62
62
|
commonmeta/writers/bibtex_writer.py,sha256=s3hIJIgWvSG7TAriZMRQEAyuitw6ebwWSI1YcYFQ-do,4971
|
63
63
|
commonmeta/writers/citation_writer.py,sha256=RjaNh9EALxq6gfODLRWVJxGxPArGd6ZiHUlkYnCT6MA,2355
|
@@ -65,11 +65,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=2qlttCfYpGhfVjrYkjzbIra7AywssRLT3
|
|
65
65
|
commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
|
66
66
|
commonmeta/writers/csl_writer.py,sha256=rlCeShkvC6ui9By0yVfNCMay_JfaZ4AooUPOPg-g-2M,2819
|
67
67
|
commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_iiaQRDnV24,6233
|
68
|
-
commonmeta/writers/inveniordm_writer.py,sha256=
|
68
|
+
commonmeta/writers/inveniordm_writer.py,sha256=oWxGweLdIUSw0pcP9SHlS0XCUYV-WqiuR4owKdkAps4,5499
|
69
69
|
commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
|
70
70
|
commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
|
71
|
-
commonmeta_py-0.
|
72
|
-
commonmeta_py-0.
|
73
|
-
commonmeta_py-0.
|
74
|
-
commonmeta_py-0.
|
75
|
-
commonmeta_py-0.
|
71
|
+
commonmeta_py-0.32.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
72
|
+
commonmeta_py-0.32.dist-info/METADATA,sha256=jrhitlV03nvAJ8VaKjwqHHK6tegUJrnsvEi9TcpfbqI,8331
|
73
|
+
commonmeta_py-0.32.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
74
|
+
commonmeta_py-0.32.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
75
|
+
commonmeta_py-0.32.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|