commonmeta-py 0.56__py3-none-any.whl → 0.58__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/readers/json_feed_reader.py +7 -1
- commonmeta/utils.py +1 -0
- commonmeta/writers/inveniordm_writer.py +56 -14
- {commonmeta_py-0.56.dist-info → commonmeta_py-0.58.dist-info}/METADATA +1 -1
- {commonmeta_py-0.56.dist-info → commonmeta_py-0.58.dist-info}/RECORD +9 -9
- {commonmeta_py-0.56.dist-info → commonmeta_py-0.58.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.56.dist-info → commonmeta_py-0.58.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.56.dist-info → commonmeta_py-0.58.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
@@ -50,7 +50,9 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
|
|
50
50
|
url = None
|
51
51
|
if py_.get(meta, "blog.status", None) == "active":
|
52
52
|
url = normalize_url(meta.get("url", None))
|
53
|
-
elif py_.get(meta, "blog.status", None) == "archived"
|
53
|
+
elif py_.get(meta, "blog.status", None) == "archived" and meta.get(
|
54
|
+
"archive_url", None
|
55
|
+
):
|
54
56
|
url = normalize_url(meta.get("archive_url", None))
|
55
57
|
_id = normalize_doi(read_options.get("doi", None) or meta.get("doi", None)) or url
|
56
58
|
_type = "Article"
|
@@ -183,6 +185,7 @@ def get_references(references: list) -> list:
|
|
183
185
|
return compact(
|
184
186
|
{
|
185
187
|
"id": id_,
|
188
|
+
"key": reference.get("key", None),
|
186
189
|
"title": reference.get("title", None),
|
187
190
|
"publicationYear": reference.get("publicationYear", None),
|
188
191
|
}
|
@@ -195,6 +198,9 @@ def get_references(references: list) -> list:
|
|
195
198
|
return compact(
|
196
199
|
{
|
197
200
|
"id": id_,
|
201
|
+
"key": reference.get("key", None),
|
202
|
+
"title": reference.get("title", None),
|
203
|
+
"publicationYear": reference.get("publicationYear", None),
|
198
204
|
}
|
199
205
|
)
|
200
206
|
|
commonmeta/utils.py
CHANGED
@@ -111,6 +111,7 @@ FOS_MAPPINGS = {
|
|
111
111
|
"Agricultural biotechnology": "http://www.oecd.org/science/inno/38235147",
|
112
112
|
"Other agricultural sciences": "http://www.oecd.org/science/inno/38235147",
|
113
113
|
"Social science": "http://www.oecd.org/science/inno/38235147.pdf?5",
|
114
|
+
"Social sciences": "http://www.oecd.org/science/inno/38235147.pdf?5",
|
114
115
|
"Psychology": "http://www.oecd.org/science/inno/38235147.pdf?5.1",
|
115
116
|
"Economics and business": "http://www.oecd.org/science/inno/38235147.pdf?5.2",
|
116
117
|
"Educational sciences": "http://www.oecd.org/science/inno/38235147.pdf?5.3",
|
@@ -15,6 +15,7 @@ from ..utils import (
|
|
15
15
|
get_language,
|
16
16
|
validate_orcid,
|
17
17
|
id_from_url,
|
18
|
+
normalize_url,
|
18
19
|
FOS_MAPPINGS,
|
19
20
|
)
|
20
21
|
|
@@ -45,17 +46,12 @@ def write_inveniordm(metadata):
|
|
45
46
|
"scheme": "url",
|
46
47
|
}
|
47
48
|
)
|
48
|
-
references = [
|
49
|
-
|
50
|
-
for i in wrap(metadata.references)
|
51
|
-
if i.get("id", None)
|
52
|
-
]
|
53
|
-
relations = [
|
49
|
+
references = [to_inveniordm_reference(i) for i in wrap(metadata.references)]
|
50
|
+
related_identifiers = [
|
54
51
|
to_inveniordm_related_identifier(i)
|
55
52
|
for i in wrap(metadata.relations)
|
56
53
|
if i.get("id", None) and i.get("type", None) != "IsPartOf"
|
57
54
|
]
|
58
|
-
related_identifiers = references + relations
|
59
55
|
funding = compact(
|
60
56
|
[
|
61
57
|
to_inveniordm_funding(i)
|
@@ -129,6 +125,7 @@ def write_inveniordm(metadata):
|
|
129
125
|
if metadata.language
|
130
126
|
else None,
|
131
127
|
"identifiers": identifiers,
|
128
|
+
"references": presence(references),
|
132
129
|
"related_identifiers": presence(related_identifiers),
|
133
130
|
"funding": presence(funding),
|
134
131
|
"version": metadata.version,
|
@@ -223,19 +220,19 @@ def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
|
|
223
220
|
|
224
221
|
|
225
222
|
def to_inveniordm_related_identifier(relation: dict) -> dict:
|
226
|
-
"""Convert
|
223
|
+
"""Convert relation to inveniordm related_identifier"""
|
227
224
|
if normalize_doi(relation.get("id", None)):
|
228
225
|
identifier = doi_from_url(relation.get("id", None))
|
229
226
|
scheme = "doi"
|
230
|
-
|
227
|
+
elif normalize_url(relation.get("id", None)):
|
231
228
|
identifier = relation.get("id", None)
|
232
229
|
scheme = "url"
|
230
|
+
else:
|
231
|
+
return None
|
233
232
|
|
234
233
|
# normalize relation types
|
235
234
|
relation_type = relation.get("type")
|
236
|
-
if relation.get("type"
|
237
|
-
relation_type = "References"
|
238
|
-
elif relation.get("type") == "HasReview":
|
235
|
+
if relation.get("type") == "HasReview":
|
239
236
|
relation_type = "IsReviewedBy"
|
240
237
|
elif relation.get("type") == "IsPreprintOf":
|
241
238
|
relation_type = "IsPreviousVersionOf"
|
@@ -251,6 +248,53 @@ def to_inveniordm_related_identifier(relation: dict) -> dict:
|
|
251
248
|
)
|
252
249
|
|
253
250
|
|
251
|
+
def to_inveniordm_reference(reference: dict) -> dict:
|
252
|
+
"""Convert reference to inveniordm reference"""
|
253
|
+
if normalize_doi(reference.get("id", None)):
|
254
|
+
identifier = doi_from_url(reference.get("id", None))
|
255
|
+
scheme = "doi"
|
256
|
+
elif normalize_url(reference.get("id", None)):
|
257
|
+
identifier = reference.get("id", None)
|
258
|
+
scheme = "url"
|
259
|
+
else:
|
260
|
+
return None
|
261
|
+
|
262
|
+
if reference.get("unstructured", None) is None:
|
263
|
+
# use title as unstructured reference
|
264
|
+
if reference.get("title", None):
|
265
|
+
unstructured = reference.get("title")
|
266
|
+
else:
|
267
|
+
unstructured = "Unknown title"
|
268
|
+
|
269
|
+
if reference.get("publicationYear", None):
|
270
|
+
unstructured += " (" + reference.get("publicationYear") + ")."
|
271
|
+
|
272
|
+
return compact(
|
273
|
+
{
|
274
|
+
"reference": unstructured,
|
275
|
+
"scheme": scheme,
|
276
|
+
"identifier": identifier,
|
277
|
+
}
|
278
|
+
)
|
279
|
+
else:
|
280
|
+
unstructured = reference.get("unstructured")
|
281
|
+
|
282
|
+
# remove optional trailing period
|
283
|
+
unstructured = unstructured.rstrip(" .")
|
284
|
+
|
285
|
+
if reference.get("id", None):
|
286
|
+
# remove duplicate ID from unstructured reference
|
287
|
+
unstructured = unstructured.replace(reference.get("id"), "")
|
288
|
+
|
289
|
+
return compact(
|
290
|
+
{
|
291
|
+
"reference": unstructured,
|
292
|
+
"scheme": scheme,
|
293
|
+
"identifier": identifier,
|
294
|
+
}
|
295
|
+
)
|
296
|
+
|
297
|
+
|
254
298
|
def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
255
299
|
"""Convert funding to inveniordm funding"""
|
256
300
|
if funding.get("funderIdentifierType", None) == "ROR":
|
@@ -311,5 +355,3 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
|
311
355
|
),
|
312
356
|
}
|
313
357
|
)
|
314
|
-
|
315
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=3ZE2nD2nrsDhNQQfX4SsQmIATcGbzmZwJGNYhQG9YQA,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=AsUElA5kT2fw_Osy7Uaj2F6MKeq9yB7d5f2V-h2lh7c,3750
|
@@ -19,7 +19,7 @@ commonmeta/readers/csl_reader.py,sha256=5V_sHSJwcAWJmhB8SYk199nB96BWYX1Sq9vkQ3iE
|
|
19
19
|
commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
|
20
20
|
commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
|
21
21
|
commonmeta/readers/inveniordm_reader.py,sha256=jzv0rXzT8OCdPD_MShBXTnlwD-F9tpTX7OKZGn8smzs,7480
|
22
|
-
commonmeta/readers/json_feed_reader.py,sha256=
|
22
|
+
commonmeta/readers/json_feed_reader.py,sha256=0g5e7uBZWFEFK-Gxgf5dSgPzbAZQUW_S8ZPB7gjR0h8,14027
|
23
23
|
commonmeta/readers/kbase_reader.py,sha256=ehKXQsJyPCtaq2FmBxNb2Jb5Nktpx8pNscpmEM6N0A4,6763
|
24
24
|
commonmeta/readers/ris_reader.py,sha256=v6qOd-i2OcMTEFy5RGd3MlYthJcYSU6yzmZ5yHDzmII,3677
|
25
25
|
commonmeta/readers/schema_org_reader.py,sha256=xyWzO2XAWlI2pYVl2EbVRsUmfiWXEwP64CHRBQNRN-M,16835
|
@@ -58,7 +58,7 @@ commonmeta/resources/styles/modern-language-association.csl,sha256=HI2iU4krze1aH
|
|
58
58
|
commonmeta/resources/styles/vancouver.csl,sha256=lun3_i2oTilgsANk4LjFao2UDPQlGj_hgFgKAWC_DF8,12878
|
59
59
|
commonmeta/schema_utils.py,sha256=gg3l1jd_lFtRkQlO1DYGMVbC10nEmVTN4AWacxC4AAE,915
|
60
60
|
commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
|
61
|
-
commonmeta/utils.py,sha256=
|
61
|
+
commonmeta/utils.py,sha256=YaKAWk37DQ1-gSk9QK5s9Pm7B7jIlmaO_Vd--3HBK1o,44066
|
62
62
|
commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45qI,45
|
63
63
|
commonmeta/writers/bibtex_writer.py,sha256=s3hIJIgWvSG7TAriZMRQEAyuitw6ebwWSI1YcYFQ-do,4971
|
64
64
|
commonmeta/writers/citation_writer.py,sha256=RjaNh9EALxq6gfODLRWVJxGxPArGd6ZiHUlkYnCT6MA,2355
|
@@ -66,11 +66,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=2qlttCfYpGhfVjrYkjzbIra7AywssRLT3
|
|
66
66
|
commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
|
67
67
|
commonmeta/writers/csl_writer.py,sha256=rlCeShkvC6ui9By0yVfNCMay_JfaZ4AooUPOPg-g-2M,2819
|
68
68
|
commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_iiaQRDnV24,6233
|
69
|
-
commonmeta/writers/inveniordm_writer.py,sha256=
|
69
|
+
commonmeta/writers/inveniordm_writer.py,sha256=jjYbhgEUjb8Y0SqVbmw6af8BFtlt7CdHhXKbYO3kpu0,11401
|
70
70
|
commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
|
71
71
|
commonmeta/writers/schema_org_writer.py,sha256=5j002uCNLdlScZMNQmPjodcVWqaBh2z38zL1H4lo2hY,5741
|
72
|
-
commonmeta_py-0.
|
73
|
-
commonmeta_py-0.
|
74
|
-
commonmeta_py-0.
|
75
|
-
commonmeta_py-0.
|
76
|
-
commonmeta_py-0.
|
72
|
+
commonmeta_py-0.58.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
73
|
+
commonmeta_py-0.58.dist-info/METADATA,sha256=vml1cVguS9ID_DrMSLbZTfyUeQaRnvXYUwkBw8jaOQ4,8282
|
74
|
+
commonmeta_py-0.58.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
75
|
+
commonmeta_py-0.58.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
76
|
+
commonmeta_py-0.58.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|