commonmeta-py 0.35__py3-none-any.whl → 0.38__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 +11 -0
- commonmeta/utils.py +11 -1
- commonmeta/writers/inveniordm_writer.py +127 -9
- {commonmeta_py-0.35.dist-info → commonmeta_py-0.38.dist-info}/METADATA +1 -1
- {commonmeta_py-0.35.dist-info → commonmeta_py-0.38.dist-info}/RECORD +9 -9
- {commonmeta_py-0.35.dist-info → commonmeta_py-0.38.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.35.dist-info → commonmeta_py-0.38.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.35.dist-info → commonmeta_py-0.38.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/constants.py
CHANGED
@@ -612,3 +612,14 @@ INVENIORDM_IDENTIFIER_TYPES = {
|
|
612
612
|
"W3ID": "w3id",
|
613
613
|
"Other": "other",
|
614
614
|
}
|
615
|
+
|
616
|
+
|
617
|
+
CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS = {
|
618
|
+
"https://doi.org/10.13039/100000001": "https://ror.org/021nxhr62",
|
619
|
+
"https://doi.org/10.13039/501100000780": "https://ror.org/00k4n6c32",
|
620
|
+
"https://doi.org/10.13039/501100007601": "https://ror.org/00k4n6c32",
|
621
|
+
"https://doi.org/10.13039/501100001659": "https://ror.org/018mejw64",
|
622
|
+
"https://doi.org/10.13039/501100006390": "https://ror.org/019whta54",
|
623
|
+
"https://doi.org/10.13039/501100001711": "https://ror.org/00yjd3n13",
|
624
|
+
"https://doi.org/10.13039/501100003043": "https://ror.org/04wfr2810",
|
625
|
+
}
|
commonmeta/utils.py
CHANGED
@@ -1076,11 +1076,21 @@ def from_curie(id: Optional[str]) -> Optional[str]:
|
|
1076
1076
|
|
1077
1077
|
def issn_as_url(issn: str) -> Optional[str]:
|
1078
1078
|
"""ISSN as URL"""
|
1079
|
-
if issn is None:
|
1079
|
+
if normalize_issn(issn) is None:
|
1080
1080
|
return None
|
1081
1081
|
return f"https://portal.issn.org/resource/ISSN/{issn}"
|
1082
1082
|
|
1083
1083
|
|
1084
|
+
def issn_from_url(url: str) -> Optional[str]:
|
1085
|
+
"""ISSN from URL"""
|
1086
|
+
if url is None:
|
1087
|
+
return None
|
1088
|
+
match = re.match(r"\Ahttps://portal.issn.org/resource/ISSN/(.+)\Z", url)
|
1089
|
+
if match is None:
|
1090
|
+
return None
|
1091
|
+
return match.group(1)
|
1092
|
+
|
1093
|
+
|
1084
1094
|
def get_language(lang: str, format: str = "alpha_2") -> Optional[str]:
|
1085
1095
|
"""Provide a language string based on ISO 639, with either a name in English,
|
1086
1096
|
ISO 639-1, or ISO 639-3 code as input. Optionally format as alpha_2 (defaul),
|
@@ -2,12 +2,23 @@
|
|
2
2
|
|
3
3
|
import orjson as json
|
4
4
|
from typing import Optional
|
5
|
+
from furl import furl
|
5
6
|
|
6
7
|
from ..base_utils import compact, wrap, parse_attributes, presence
|
7
8
|
from ..date_utils import get_iso8601_date
|
8
|
-
from ..doi_utils import doi_from_url
|
9
|
-
from ..constants import
|
10
|
-
|
9
|
+
from ..doi_utils import doi_from_url, normalize_doi
|
10
|
+
from ..constants import (
|
11
|
+
CM_TO_INVENIORDM_TRANSLATIONS,
|
12
|
+
INVENIORDM_IDENTIFIER_TYPES,
|
13
|
+
CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS,
|
14
|
+
)
|
15
|
+
from ..utils import (
|
16
|
+
get_language,
|
17
|
+
validate_orcid,
|
18
|
+
id_from_url,
|
19
|
+
issn_from_url,
|
20
|
+
FOS_MAPPINGS,
|
21
|
+
)
|
11
22
|
|
12
23
|
|
13
24
|
def write_inveniordm(metadata):
|
@@ -30,6 +41,26 @@ def write_inveniordm(metadata):
|
|
30
41
|
for i in wrap(metadata.identifiers)
|
31
42
|
if i.get("id", None) != metadata.id
|
32
43
|
]
|
44
|
+
print(metadata.references)
|
45
|
+
print(metadata.relations)
|
46
|
+
references = [
|
47
|
+
to_inveniordm_related_identifier(i)
|
48
|
+
for i in wrap(metadata.references)
|
49
|
+
if i.get("id", None)
|
50
|
+
]
|
51
|
+
relations = [
|
52
|
+
to_inveniordm_related_identifier(i)
|
53
|
+
for i in wrap(metadata.relations)
|
54
|
+
if i.get("id", None) and i.get("type", None)
|
55
|
+
]
|
56
|
+
related_identifiers = references + relations
|
57
|
+
funding = compact(
|
58
|
+
[
|
59
|
+
to_inveniordm_funding(i)
|
60
|
+
for i in wrap(metadata.funding_references)
|
61
|
+
if i.get("funderName", None)
|
62
|
+
]
|
63
|
+
)
|
33
64
|
container = metadata.container if metadata.container else {}
|
34
65
|
journal = (
|
35
66
|
container.get("title", None)
|
@@ -42,6 +73,14 @@ def write_inveniordm(metadata):
|
|
42
73
|
if container.get("identifierType", None) == "ISSN"
|
43
74
|
else None
|
44
75
|
)
|
76
|
+
dates = []
|
77
|
+
if metadata.date.get("updated", None):
|
78
|
+
dates.append(
|
79
|
+
{
|
80
|
+
"date": metadata.date.get("updated"),
|
81
|
+
"type": {"id": "updated"},
|
82
|
+
}
|
83
|
+
)
|
45
84
|
|
46
85
|
subjects = [to_inveniordm_subject(i) for i in wrap(metadata.subjects)]
|
47
86
|
data = compact(
|
@@ -67,12 +106,7 @@ def write_inveniordm(metadata):
|
|
67
106
|
"publication_date": get_iso8601_date(metadata.date.get("published"))
|
68
107
|
if metadata.date.get("published", None)
|
69
108
|
else None,
|
70
|
-
"dates":
|
71
|
-
{
|
72
|
-
"date": metadata.date.get("updated"),
|
73
|
-
"type": {"id": "updated"},
|
74
|
-
}
|
75
|
-
]),
|
109
|
+
"dates": presence(dates),
|
76
110
|
"subjects": presence(subjects),
|
77
111
|
"description": parse_attributes(
|
78
112
|
metadata.descriptions, content="description", first=True
|
@@ -86,6 +120,8 @@ def write_inveniordm(metadata):
|
|
86
120
|
if metadata.language
|
87
121
|
else None,
|
88
122
|
"identifiers": identifiers,
|
123
|
+
"related_identifiers": presence(related_identifiers),
|
124
|
+
"funding": presence(funding),
|
89
125
|
"version": metadata.version,
|
90
126
|
}
|
91
127
|
),
|
@@ -171,3 +207,85 @@ def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
|
|
171
207
|
return compact(
|
172
208
|
[format_affiliation(i) for i in wrap(creator.get("affiliations", None))]
|
173
209
|
)
|
210
|
+
|
211
|
+
|
212
|
+
def to_inveniordm_related_identifier(relation: dict) -> dict:
|
213
|
+
"""Convert reference or relation to inveniordm related_identifier"""
|
214
|
+
if normalize_doi(relation.get("id", None)):
|
215
|
+
identifier = doi_from_url(relation.get("id", None))
|
216
|
+
scheme = "doi"
|
217
|
+
elif (
|
218
|
+
relation.get("type", None) == "IsPartOf"
|
219
|
+
and furl(relation.get("id", None)).host == "portal.issn.org"
|
220
|
+
):
|
221
|
+
identifier = issn_from_url(relation.get("id", None))
|
222
|
+
scheme = "issn"
|
223
|
+
else:
|
224
|
+
identifier = relation.get("id", None)
|
225
|
+
scheme = "url"
|
226
|
+
|
227
|
+
# normalize relation types
|
228
|
+
if relation.get("type", None) is None:
|
229
|
+
relation["type"] = "References"
|
230
|
+
if relation.get("type") == "HasReview":
|
231
|
+
relation["type"] = "IsReviewedBy"
|
232
|
+
relation_type = relation.get("type").lower()
|
233
|
+
return compact(
|
234
|
+
{
|
235
|
+
"identifier": identifier,
|
236
|
+
"scheme": scheme,
|
237
|
+
"relation_type": {
|
238
|
+
"id": relation_type,
|
239
|
+
},
|
240
|
+
}
|
241
|
+
)
|
242
|
+
|
243
|
+
|
244
|
+
def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
245
|
+
"""Convert funding to inveniordm funding"""
|
246
|
+
if funding.get("funderIdentifierType", None) == "ROR":
|
247
|
+
funder_identifier = id_from_url(funder_identifier)
|
248
|
+
elif funding.get("funderIdentifierType", None) == "Crossref Funder ID":
|
249
|
+
# convert to ROR
|
250
|
+
funder_identifier = id_from_url(
|
251
|
+
CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS.get(
|
252
|
+
funding.get("funderIdentifier", None), None
|
253
|
+
)
|
254
|
+
)
|
255
|
+
else:
|
256
|
+
funder_identifier = None
|
257
|
+
award_title = funding.get("awardTitle", None)
|
258
|
+
if award_title:
|
259
|
+
award_title = {"title": {"en": award_title}}
|
260
|
+
if funding.get("awardUri", None):
|
261
|
+
award_identifiers = [
|
262
|
+
{
|
263
|
+
"scheme": "url",
|
264
|
+
"identifier": funding.get("awardUri", None),
|
265
|
+
},
|
266
|
+
]
|
267
|
+
else:
|
268
|
+
award_identifiers = None
|
269
|
+
if funding.get("awardNumber", None) or award_title or award_identifiers:
|
270
|
+
award = (
|
271
|
+
compact(
|
272
|
+
{
|
273
|
+
"number": funding.get("awardNumber", None),
|
274
|
+
"title": award_title,
|
275
|
+
"identifiers": award_identifiers,
|
276
|
+
}
|
277
|
+
),
|
278
|
+
)
|
279
|
+
else:
|
280
|
+
award = None
|
281
|
+
return compact(
|
282
|
+
{
|
283
|
+
"funder": compact(
|
284
|
+
{
|
285
|
+
"name": funding.get("funderName"),
|
286
|
+
"id": funder_identifier,
|
287
|
+
}
|
288
|
+
),
|
289
|
+
"award": award,
|
290
|
+
}
|
291
|
+
)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=s5OSvyoLPJlih0ohip5DGhb84c9rFKXbEFMkyidzEG4,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=aMD7vG_kJD5ja5YOqDjsfuokWcRMnWOF7jv0YV3-OXw,16973
|
7
7
|
commonmeta/crossref_utils.py,sha256=xyS8jFXO8unzumCC6YXK45kzz16PQAAOkWUHgjqawAo,22063
|
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=dblEYOmR0q6qZgsqnQOunm_Zj7YP4bugzwK1ps5SYq8,42583
|
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=xOLIrWTSXYDmri80yUuZmoU257UX9ojpkVf3JeHLyUM,9252
|
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.38.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
72
|
+
commonmeta_py-0.38.dist-info/METADATA,sha256=SyjvOE8BUdQ_1xOaiEPIigazkzniQ9oBo6YRsrxIsOY,8331
|
73
|
+
commonmeta_py-0.38.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
74
|
+
commonmeta_py-0.38.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
75
|
+
commonmeta_py-0.38.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|