commonmeta-py 0.55__py3-none-any.whl → 0.57__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 +71 -24
- {commonmeta_py-0.55.dist-info → commonmeta_py-0.57.dist-info}/METADATA +1 -1
- {commonmeta_py-0.55.dist-info → commonmeta_py-0.57.dist-info}/RECORD +9 -9
- {commonmeta_py-0.55.dist-info → commonmeta_py-0.57.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.55.dist-info → commonmeta_py-0.57.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.55.dist-info → commonmeta_py-0.57.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)
|
@@ -76,16 +72,20 @@ def write_inveniordm(metadata):
|
|
76
72
|
else None
|
77
73
|
)
|
78
74
|
dates = []
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
75
|
+
for date in metadata.date.keys():
|
76
|
+
if metadata.date.get(date, None) is None:
|
77
|
+
continue
|
78
|
+
t = date.lower()
|
79
|
+
if t == "published":
|
80
|
+
t = "issued"
|
81
|
+
elif t == "accessed":
|
82
|
+
t = "other"
|
83
|
+
dates.append(
|
84
|
+
{
|
85
|
+
"date": metadata.date.get(date),
|
86
|
+
"type": {"id": t},
|
87
|
+
}
|
88
|
+
)
|
89
89
|
|
90
90
|
subjects = [to_inveniordm_subject(i) for i in wrap(metadata.subjects)]
|
91
91
|
data = compact(
|
@@ -125,6 +125,7 @@ def write_inveniordm(metadata):
|
|
125
125
|
if metadata.language
|
126
126
|
else None,
|
127
127
|
"identifiers": identifiers,
|
128
|
+
"references": presence(references),
|
128
129
|
"related_identifiers": presence(related_identifiers),
|
129
130
|
"funding": presence(funding),
|
130
131
|
"version": metadata.version,
|
@@ -219,19 +220,19 @@ def to_inveniordm_affiliations(creator: dict) -> Optional[list]:
|
|
219
220
|
|
220
221
|
|
221
222
|
def to_inveniordm_related_identifier(relation: dict) -> dict:
|
222
|
-
"""Convert
|
223
|
+
"""Convert relation to inveniordm related_identifier"""
|
223
224
|
if normalize_doi(relation.get("id", None)):
|
224
225
|
identifier = doi_from_url(relation.get("id", None))
|
225
226
|
scheme = "doi"
|
226
|
-
|
227
|
+
elif normalize_url(relation.get("id", None)):
|
227
228
|
identifier = relation.get("id", None)
|
228
229
|
scheme = "url"
|
230
|
+
else:
|
231
|
+
return None
|
229
232
|
|
230
233
|
# normalize relation types
|
231
234
|
relation_type = relation.get("type")
|
232
|
-
if relation.get("type"
|
233
|
-
relation_type = "References"
|
234
|
-
elif relation.get("type") == "HasReview":
|
235
|
+
if relation.get("type") == "HasReview":
|
235
236
|
relation_type = "IsReviewedBy"
|
236
237
|
elif relation.get("type") == "IsPreprintOf":
|
237
238
|
relation_type = "IsPreviousVersionOf"
|
@@ -247,6 +248,54 @@ def to_inveniordm_related_identifier(relation: dict) -> dict:
|
|
247
248
|
)
|
248
249
|
|
249
250
|
|
251
|
+
def to_inveniordm_reference(reference: dict) -> dict:
|
252
|
+
"""Convert reference to inveniordm reference"""
|
253
|
+
print(reference)
|
254
|
+
if normalize_doi(reference.get("id", None)):
|
255
|
+
identifier = doi_from_url(reference.get("id", None))
|
256
|
+
scheme = "doi"
|
257
|
+
elif normalize_url(reference.get("id", None)):
|
258
|
+
identifier = reference.get("id", None)
|
259
|
+
scheme = "url"
|
260
|
+
else:
|
261
|
+
return None
|
262
|
+
|
263
|
+
if reference.get("unstructured", None) is None:
|
264
|
+
# use title as unstructured reference
|
265
|
+
if reference.get("title", None):
|
266
|
+
unstructured = reference.get("title")
|
267
|
+
else:
|
268
|
+
unstructured = "Unknown title"
|
269
|
+
|
270
|
+
if reference.get("publicationYear", None):
|
271
|
+
unstructured += " (" + reference.get("publicationYear") + ")."
|
272
|
+
|
273
|
+
return compact(
|
274
|
+
{
|
275
|
+
"reference": unstructured,
|
276
|
+
"scheme": scheme,
|
277
|
+
"identifier": identifier,
|
278
|
+
}
|
279
|
+
)
|
280
|
+
else:
|
281
|
+
unstructured = reference.get("unstructured")
|
282
|
+
|
283
|
+
# remove optional trailing period
|
284
|
+
unstructured = unstructured.rstrip(" .")
|
285
|
+
|
286
|
+
if reference.get("id", None):
|
287
|
+
# remove duplicate ID from unstructured reference
|
288
|
+
unstructured = unstructured.replace(reference.get("id"), "")
|
289
|
+
|
290
|
+
return compact(
|
291
|
+
{
|
292
|
+
"reference": unstructured,
|
293
|
+
"scheme": scheme,
|
294
|
+
"identifier": identifier,
|
295
|
+
}
|
296
|
+
)
|
297
|
+
|
298
|
+
|
250
299
|
def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
251
300
|
"""Convert funding to inveniordm funding"""
|
252
301
|
if funding.get("funderIdentifierType", None) == "ROR":
|
@@ -307,5 +356,3 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
|
307
356
|
),
|
308
357
|
}
|
309
358
|
)
|
310
|
-
|
311
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=X8zPmm3FIxB46NHT9abDSezCrBfHCzcwmvQRbG_p_J0,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=2EptJ9H328vqXlEm9d0delY101zdPt4c-_gIzEz-saY,11422
|
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.57.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
73
|
+
commonmeta_py-0.57.dist-info/METADATA,sha256=OAb3iqk3hSgEWg6J1PU57i6hPhSiUkaxsgvaaLeA5CU,8282
|
74
|
+
commonmeta_py-0.57.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
75
|
+
commonmeta_py-0.57.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
76
|
+
commonmeta_py-0.57.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|