commonmeta-py 0.38__py3-none-any.whl → 0.40__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 +10 -0
- commonmeta/crossref_utils.py +7 -2
- commonmeta/readers/inveniordm_reader.py +0 -2
- commonmeta/readers/json_feed_reader.py +33 -49
- commonmeta/readers/kbase_reader.py +1 -1
- commonmeta/resources/commonmeta_v0.15.json +574 -0
- commonmeta/schema_utils.py +1 -1
- commonmeta/writers/inveniordm_writer.py +32 -21
- {commonmeta_py-0.38.dist-info → commonmeta_py-0.40.dist-info}/METADATA +1 -1
- {commonmeta_py-0.38.dist-info → commonmeta_py-0.40.dist-info}/RECORD +14 -13
- {commonmeta_py-0.38.dist-info → commonmeta_py-0.40.dist-info}/LICENSE +0 -0
- {commonmeta_py-0.38.dist-info → commonmeta_py-0.40.dist-info}/WHEEL +0 -0
- {commonmeta_py-0.38.dist-info → commonmeta_py-0.40.dist-info}/entry_points.txt +0 -0
commonmeta/__init__.py
CHANGED
commonmeta/constants.py
CHANGED
@@ -623,3 +623,13 @@ CROSSREF_FUNDER_ID_TO_ROR_TRANSLATIONS = {
|
|
623
623
|
"https://doi.org/10.13039/501100001711": "https://ror.org/00yjd3n13",
|
624
624
|
"https://doi.org/10.13039/501100003043": "https://ror.org/04wfr2810",
|
625
625
|
}
|
626
|
+
|
627
|
+
|
628
|
+
ROR_TO_CROSSREF_FUNDER_ID_TRANSLATIONS = {
|
629
|
+
"https://ror.org/021nxhr62": "https://doi.org/10.13039/100000001",
|
630
|
+
"https://ror.org/00k4n6c32": "https://doi.org/10.13039/501100000780",
|
631
|
+
"https://ror.org/018mejw64": "https://doi.org/10.13039/501100001659",
|
632
|
+
"https://ror.org/019whta54": "https://doi.org/10.13039/501100006390",
|
633
|
+
"https://ror.org/00yjd3n13": "https://doi.org/10.13039/501100001711",
|
634
|
+
"https://ror.org/04wfr2810": "https://doi.org/10.13039/501100003043",
|
635
|
+
}
|
commonmeta/crossref_utils.py
CHANGED
@@ -8,7 +8,7 @@ import uuid
|
|
8
8
|
import pydash as py_
|
9
9
|
from furl import furl
|
10
10
|
|
11
|
-
from .constants import Commonmeta
|
11
|
+
from .constants import Commonmeta, ROR_TO_CROSSREF_FUNDER_ID_TRANSLATIONS
|
12
12
|
from .utils import wrap, compact, normalize_orcid, normalize_id, validate_url
|
13
13
|
from .doi_utils import doi_from_url, validate_doi
|
14
14
|
|
@@ -362,11 +362,16 @@ def insert_funding_references(metadata, xml):
|
|
362
362
|
{"name": "funder_name"},
|
363
363
|
)
|
364
364
|
if funding_reference.get("funderIdentifier", None) is not None:
|
365
|
+
funder_identifier = funding_reference.get("funderIdentifier", None)
|
366
|
+
|
367
|
+
# translate ROR to Crossref funder ID until Crossref supports ROR
|
368
|
+
funder_identifier = ROR_TO_CROSSREF_FUNDER_ID_TRANSLATIONS.get(funder_identifier, funder_identifier)
|
369
|
+
|
365
370
|
etree.SubElement(
|
366
371
|
funder_name,
|
367
372
|
"assertion",
|
368
373
|
{"name": "funder_identifier"},
|
369
|
-
).text =
|
374
|
+
).text = funder_identifier
|
370
375
|
if funding_reference.get("awardNumber", None) is not None:
|
371
376
|
etree.SubElement(
|
372
377
|
assertion,
|
@@ -36,7 +36,6 @@ def get_inveniordm(pid: str, **kwargs) -> dict:
|
|
36
36
|
|
37
37
|
def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
|
38
38
|
"""read_inveniordm"""
|
39
|
-
print(data)
|
40
39
|
meta = data
|
41
40
|
read_options = kwargs or {}
|
42
41
|
|
@@ -49,7 +48,6 @@ def read_inveniordm(data: dict, **kwargs) -> Commonmeta:
|
|
49
48
|
resource_type = py_.get(meta, "metadata.resource_type.type") or py_.get(
|
50
49
|
meta, "metadata.resource_type.id"
|
51
50
|
)
|
52
|
-
print(resource_type)
|
53
51
|
_type = INVENIORDM_TO_CM_TRANSLATIONS.get(resource_type, "Other")
|
54
52
|
|
55
53
|
contributors = py_.get(meta, "metadata.creators")
|
@@ -46,7 +46,6 @@ def read_json_feed_item(data: Optional[dict], **kwargs) -> Commonmeta:
|
|
46
46
|
if data is None:
|
47
47
|
return {"state": "not_found"}
|
48
48
|
meta = data
|
49
|
-
print(meta)
|
50
49
|
read_options = kwargs or {}
|
51
50
|
|
52
51
|
url = normalize_url(meta.get("url", None))
|
@@ -168,39 +167,28 @@ def get_references(references: list) -> list:
|
|
168
167
|
def get_reference(reference: dict) -> Optional[dict]:
|
169
168
|
if reference is None or not isinstance(reference, dict):
|
170
169
|
return None
|
171
|
-
try:
|
172
|
-
if reference.get("doi", None) and validate_doi(reference.get("doi")):
|
173
|
-
id_ = normalize_doi(reference.get("doi"))
|
174
|
-
return compact(
|
175
|
-
{
|
176
|
-
"id": id_,
|
177
|
-
"title": reference.get("title", None),
|
178
|
-
"publicationYear": reference.get("publicationYear", None),
|
179
|
-
}
|
180
|
-
)
|
181
170
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
if response.status_code in [404]:
|
190
|
-
return None
|
191
|
-
return {
|
192
|
-
"id": reference.get("url"),
|
171
|
+
if reference.get("id", None) and validate_doi(reference.get("id")):
|
172
|
+
id_ = normalize_doi(reference.get("id"))
|
173
|
+
return compact(
|
174
|
+
{
|
175
|
+
"id": id_,
|
176
|
+
"title": reference.get("title", None),
|
177
|
+
"publicationYear": reference.get("publicationYear", None),
|
193
178
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
179
|
+
)
|
180
|
+
|
181
|
+
else:
|
182
|
+
return {
|
183
|
+
"id": reference.get("id", None),
|
184
|
+
}
|
197
185
|
|
198
186
|
def number_reference(reference: dict, index: int) -> dict:
|
199
187
|
"""number reference"""
|
200
188
|
reference["key"] = f"ref{index +1}"
|
201
189
|
return reference
|
202
190
|
|
203
|
-
references = [get_reference(i) for i in references]
|
191
|
+
references = [get_reference(i) for i in references if i.get("id", None)]
|
204
192
|
return [
|
205
193
|
number_reference(i, index)
|
206
194
|
for index, i in enumerate(references)
|
@@ -226,13 +214,15 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
|
|
226
214
|
or furl(urls[0]).host == "cordis.europa.eu"
|
227
215
|
):
|
228
216
|
return [
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
217
|
+
compact(
|
218
|
+
{
|
219
|
+
"funderName": "European Commission",
|
220
|
+
"funderIdentifier": "https://ror.org/00k4n6c32",
|
221
|
+
"funderIdentifierType": "ROR",
|
222
|
+
"awardUri": urls[0],
|
223
|
+
"awardNumber": urls[0].split("/")[-1],
|
224
|
+
}
|
225
|
+
)
|
236
226
|
]
|
237
227
|
# Prefix 10.13039 means funder ID from Open Funder registry.
|
238
228
|
elif len(urls) == 2 and validate_prefix(urls[0]) == "10.13039":
|
@@ -247,29 +237,24 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
|
|
247
237
|
else:
|
248
238
|
award_number = f.path.segments[-1]
|
249
239
|
return [
|
250
|
-
{
|
240
|
+
compact({
|
251
241
|
"funderName": funder_name,
|
252
242
|
"funderIdentifier": urls[0],
|
253
243
|
"funderIdentifierType": "Crossref Funder ID",
|
254
|
-
"
|
244
|
+
"awardUri": urls[1],
|
255
245
|
"awardNumber": award_number,
|
256
|
-
}
|
246
|
+
})
|
257
247
|
]
|
258
|
-
# URL is ROR ID for funder.
|
259
|
-
# until Crossref production service supports ROR IDs.
|
248
|
+
# URL is ROR ID for funder.
|
260
249
|
elif len(urls) == 2 and validate_ror(urls[0]):
|
261
250
|
f = furl(urls[0])
|
262
251
|
_id = f.path.segments[-1]
|
263
252
|
response = httpx.get(f"https://api.ror.org/organizations/{_id}", timeout=10)
|
264
253
|
ror = response.json()
|
265
254
|
funder_name = ror.get("name", None)
|
266
|
-
funder_identifier =
|
267
|
-
|
268
|
-
|
269
|
-
funder_identifier_type = "Crossref Funder ID"
|
270
|
-
else:
|
271
|
-
funder_identifier = urls[0]
|
272
|
-
funder_identifier_type = "ROR"
|
255
|
+
funder_identifier = urls[0]
|
256
|
+
funder_identifier_type = "ROR"
|
257
|
+
|
273
258
|
f = furl(urls[1])
|
274
259
|
# url is for NSF grant
|
275
260
|
if f.args["awd_id"] is not None:
|
@@ -278,13 +263,13 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
|
|
278
263
|
award_number = f.path.segments[-1]
|
279
264
|
return [
|
280
265
|
compact(
|
281
|
-
{
|
266
|
+
compact({
|
282
267
|
"funderName": funder_name,
|
283
268
|
"funderIdentifier": funder_identifier,
|
284
269
|
"funderIdentifierType": funder_identifier_type,
|
285
|
-
"
|
270
|
+
"awardUri": urls[1],
|
286
271
|
"awardNumber": award_number,
|
287
|
-
}
|
272
|
+
})
|
288
273
|
)
|
289
274
|
]
|
290
275
|
|
@@ -302,7 +287,6 @@ def get_funding_references(meta: Optional[dict]) -> Optional[list]:
|
|
302
287
|
"funderName": funding.get("funder_name", None),
|
303
288
|
"funderIdentifier": funding.get("funder_id", None),
|
304
289
|
"funderIdentifierType": "Crossref Funder ID",
|
305
|
-
"awardTitle": funding.get("award", None),
|
306
290
|
"awardNumber": funding.get("award_number", None),
|
307
291
|
}
|
308
292
|
]
|
@@ -186,7 +186,7 @@ def get_funding_references(funding_references: list) -> list:
|
|
186
186
|
funding_reference, "funder.organization_name", None
|
187
187
|
),
|
188
188
|
"awardNumber": funding_reference.get("grant_id", None),
|
189
|
-
"
|
189
|
+
"awardUri": funding_reference.get("grant_url", None),
|
190
190
|
}
|
191
191
|
)
|
192
192
|
|
@@ -0,0 +1,574 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
+
"$id": "https://commonmeta.org/commonmeta_v0.15.json",
|
4
|
+
"title": "Commonmeta v0.15",
|
5
|
+
"description": "JSON representation of the Commonmeta schema.",
|
6
|
+
"commonmeta": {
|
7
|
+
"anyOf": [
|
8
|
+
{ "$ref": "#/definitions/commonmeta"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"type": "array",
|
12
|
+
"description": "An array of commonmeta objects.",
|
13
|
+
"items": { "$ref": "#/definitions/commonmeta" }
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"definitions": {
|
18
|
+
"affiliations": {
|
19
|
+
"type": "array",
|
20
|
+
"items": {
|
21
|
+
"type": "object",
|
22
|
+
"properties": {
|
23
|
+
"organization": { "$ref": "#/definitions/organization" }
|
24
|
+
}
|
25
|
+
}
|
26
|
+
},
|
27
|
+
"commonmeta": {
|
28
|
+
"description": "A commonmeta object.",
|
29
|
+
"type": "object",
|
30
|
+
"additionalProperties": false,
|
31
|
+
"properties": {
|
32
|
+
"id": { "$ref": "#/definitions/id" },
|
33
|
+
"type": { "$ref": "#/definitions/type" },
|
34
|
+
"additionalType": {
|
35
|
+
"description": "The additional type of the resource.",
|
36
|
+
"type": "string"
|
37
|
+
},
|
38
|
+
"archiveLocations": {
|
39
|
+
"description": "The location where content is archived.",
|
40
|
+
"type": "array",
|
41
|
+
"items": {
|
42
|
+
"type": "string",
|
43
|
+
"enum": [
|
44
|
+
"CLOCKSS",
|
45
|
+
"LOCKSS",
|
46
|
+
"Portico",
|
47
|
+
"KB",
|
48
|
+
"Internet Archive",
|
49
|
+
"DWT"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"container": {
|
54
|
+
"description": "The container of the resource.",
|
55
|
+
"type": "object",
|
56
|
+
"properties": {
|
57
|
+
"identifier": {
|
58
|
+
"description": "The identifier for the container.",
|
59
|
+
"type": "string"
|
60
|
+
},
|
61
|
+
"identifierType": {
|
62
|
+
"description": "The identifierType for the container.",
|
63
|
+
"type": "string"
|
64
|
+
},
|
65
|
+
"type": {
|
66
|
+
"description": "The type of the container.",
|
67
|
+
"type": "string",
|
68
|
+
"enum": [
|
69
|
+
"Book",
|
70
|
+
"BookSeries",
|
71
|
+
"Journal",
|
72
|
+
"Proceedings",
|
73
|
+
"ProceedingsSeries",
|
74
|
+
"Repository",
|
75
|
+
"DataRepository",
|
76
|
+
"Periodical",
|
77
|
+
"Series"
|
78
|
+
]
|
79
|
+
},
|
80
|
+
"title": {
|
81
|
+
"description": "The title of the container.",
|
82
|
+
"type": "string"
|
83
|
+
},
|
84
|
+
"firstPage": {
|
85
|
+
"description": "The first page of the resource.",
|
86
|
+
"type": "string"
|
87
|
+
},
|
88
|
+
"lastPage": {
|
89
|
+
"description": "The last page of the resource.",
|
90
|
+
"type": "string"
|
91
|
+
},
|
92
|
+
"volume": {
|
93
|
+
"description": "The volume of the resource.",
|
94
|
+
"type": "string"
|
95
|
+
},
|
96
|
+
"issue": {
|
97
|
+
"description": "The issue of the resource.",
|
98
|
+
"type": "string"
|
99
|
+
}
|
100
|
+
}
|
101
|
+
},
|
102
|
+
"contributors": {
|
103
|
+
"description": "The contributors to the resource.",
|
104
|
+
"type": "array",
|
105
|
+
"items": {
|
106
|
+
"type": "object",
|
107
|
+
"properties": {
|
108
|
+
"organization": { "$ref": "#/definitions/organization" },
|
109
|
+
"person": { "$ref": "#/definitions/person" },
|
110
|
+
"contributorRoles": {
|
111
|
+
"description": "List of roles assumed by the contributor when working on the resource.",
|
112
|
+
"items": {
|
113
|
+
"$ref": "#/definitions/contributorRole"
|
114
|
+
},
|
115
|
+
"type": "array"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
},
|
119
|
+
"minItems": 1
|
120
|
+
},
|
121
|
+
"date": {
|
122
|
+
"description": "The dates for the resource.",
|
123
|
+
"$comment": "The date fields are not required. Dates should be formatted as ISO 8601 dates.",
|
124
|
+
"type": "object",
|
125
|
+
"properties": {
|
126
|
+
"created": {
|
127
|
+
"description": "The date the resource was created.",
|
128
|
+
"type": "string"
|
129
|
+
},
|
130
|
+
"submitted": {
|
131
|
+
"description": "The date the resource was submitted.",
|
132
|
+
"type": "string"
|
133
|
+
},
|
134
|
+
"accepted": {
|
135
|
+
"description": "The date the resource was accepted.",
|
136
|
+
"type": "string"
|
137
|
+
},
|
138
|
+
"published": {
|
139
|
+
"description": "The date the resource was published.",
|
140
|
+
"type": "string"
|
141
|
+
},
|
142
|
+
"updated": {
|
143
|
+
"description": "The date the resource was updated.",
|
144
|
+
"type": "string"
|
145
|
+
},
|
146
|
+
"accessed": {
|
147
|
+
"description": "The date the resource was accessed.",
|
148
|
+
"type": "string"
|
149
|
+
},
|
150
|
+
"available": {
|
151
|
+
"description": "The date the resource was made available.",
|
152
|
+
"type": "string"
|
153
|
+
},
|
154
|
+
"withdrawn": {
|
155
|
+
"description": "The date the resource was withdrawn.",
|
156
|
+
"type": "string"
|
157
|
+
}
|
158
|
+
}
|
159
|
+
},
|
160
|
+
"descriptions": {
|
161
|
+
"description": "The descriptions of the resource.",
|
162
|
+
"type": "array",
|
163
|
+
"items": {
|
164
|
+
"type": "object",
|
165
|
+
"properties": {
|
166
|
+
"description": {
|
167
|
+
"description": "The description of the resource.",
|
168
|
+
"type": "string"
|
169
|
+
},
|
170
|
+
"type": {
|
171
|
+
"description": "The type of the description.",
|
172
|
+
"type": "string",
|
173
|
+
"enum": ["Abstract", "Summary", "Methods", "TechnicalInfo", "Other"]
|
174
|
+
},
|
175
|
+
"language": {
|
176
|
+
"description": "The language of the title. Use one of the language codes from the IETF BCP 47 standard.",
|
177
|
+
"type": "string"
|
178
|
+
}
|
179
|
+
},
|
180
|
+
"required": ["description"]
|
181
|
+
}
|
182
|
+
},
|
183
|
+
"files": {
|
184
|
+
"description": "The downloadable files for the resource.",
|
185
|
+
"type": "array",
|
186
|
+
"items": {
|
187
|
+
"type": "object",
|
188
|
+
"properties": {
|
189
|
+
"bucket": { "type": "string" },
|
190
|
+
"key": { "type": "string" },
|
191
|
+
"checksum": { "type": "string" },
|
192
|
+
"url": { "type": "string", "format": "uri" },
|
193
|
+
"size": { "type": "integer" },
|
194
|
+
"mimeType": { "type": "string" }
|
195
|
+
},
|
196
|
+
"required": ["url"]
|
197
|
+
},
|
198
|
+
"minItems": 1
|
199
|
+
},
|
200
|
+
"fundingReferences": {
|
201
|
+
"description": "The funding references for the resource.",
|
202
|
+
"type": "array",
|
203
|
+
"items": {
|
204
|
+
"type": "object",
|
205
|
+
"properties": {
|
206
|
+
"funderIdentifier": { "type": "string" },
|
207
|
+
"funderIdentifierType": {
|
208
|
+
"type": "string",
|
209
|
+
"enum": [
|
210
|
+
"Crossref Funder ID",
|
211
|
+
"ROR",
|
212
|
+
"GRID",
|
213
|
+
"ISNI",
|
214
|
+
"Ringgold",
|
215
|
+
"Other"
|
216
|
+
]
|
217
|
+
},
|
218
|
+
"funderName": { "type": "string" },
|
219
|
+
"awardNumber": { "type": "string" },
|
220
|
+
"awardTitle": { "type": "string" },
|
221
|
+
"awardUri": { "type": "string", "format": "uri" }
|
222
|
+
},
|
223
|
+
"required": ["funderName"]
|
224
|
+
}
|
225
|
+
},
|
226
|
+
"geoLocations": {
|
227
|
+
"type": "array",
|
228
|
+
"items": {
|
229
|
+
"type": "object",
|
230
|
+
"properties": {
|
231
|
+
"geoLocationPlace": { "type": "string" },
|
232
|
+
"geoLocationPoint": { "$ref": "#/definitions/geoLocationPoint" },
|
233
|
+
"geoLocationBox": { "$ref": "#/definitions/geoLocationBox" },
|
234
|
+
"geoLocationPolygons": {
|
235
|
+
"type": "array",
|
236
|
+
"items": {
|
237
|
+
"type": "object",
|
238
|
+
"properties": {
|
239
|
+
"polygonPoints": {
|
240
|
+
"type": "array",
|
241
|
+
"items": { "$ref": "#/definitions/geoLocationPoint" },
|
242
|
+
"minItems": 4
|
243
|
+
},
|
244
|
+
"inPolygonPoint": { "$ref": "#/definitions/geoLocationPoint" }
|
245
|
+
},
|
246
|
+
"required": ["polygonPoints"]
|
247
|
+
},
|
248
|
+
"uniqueItems": true
|
249
|
+
}
|
250
|
+
}
|
251
|
+
},
|
252
|
+
"uniqueItems": true
|
253
|
+
},
|
254
|
+
"identifiers": {
|
255
|
+
"description": "Identifiers for the resource, including the id.",
|
256
|
+
"type": "array",
|
257
|
+
"items": {
|
258
|
+
"type": "object",
|
259
|
+
"properties": {
|
260
|
+
"identifier": { "type": "string" },
|
261
|
+
"identifierType": {
|
262
|
+
"type": "string",
|
263
|
+
"enum": [
|
264
|
+
"ARK",
|
265
|
+
"arXiv",
|
266
|
+
"Bibcode",
|
267
|
+
"DOI",
|
268
|
+
"Handle",
|
269
|
+
"ISBN",
|
270
|
+
"ISSN",
|
271
|
+
"PMID",
|
272
|
+
"PMCID",
|
273
|
+
"PURL",
|
274
|
+
"URL",
|
275
|
+
"URN",
|
276
|
+
"UUID",
|
277
|
+
"Other"
|
278
|
+
]
|
279
|
+
}
|
280
|
+
},
|
281
|
+
"required": ["identifier", "identifierType"]
|
282
|
+
}
|
283
|
+
},
|
284
|
+
"language": {
|
285
|
+
"description": "The language of the resource. Use one of the language codes from the IETF BCP 47 standard.",
|
286
|
+
"type": "string"
|
287
|
+
},
|
288
|
+
"license": {
|
289
|
+
"description": "The license for the resource. Use one of the SPDX license identifiers.",
|
290
|
+
"type": "object",
|
291
|
+
"properties": {
|
292
|
+
"id": { "type": "string" },
|
293
|
+
"url": { "type": "string", "format": "uri" }
|
294
|
+
}
|
295
|
+
},
|
296
|
+
"provider": {
|
297
|
+
"description": "The provider of the resource. This can be a DOI registration agency or a repository.",
|
298
|
+
"type": "string",
|
299
|
+
"enum": ["Crossref", "DataCite", "GitHub", "JaLC", "KISTI", "mEDRA", "OP"]
|
300
|
+
},
|
301
|
+
"publisher": {
|
302
|
+
"description": "The publisher of the resource.",
|
303
|
+
"type": "object",
|
304
|
+
"properties": {
|
305
|
+
"organization": { "$ref": "#/definitions/organization" }
|
306
|
+
}
|
307
|
+
},
|
308
|
+
"relations": {
|
309
|
+
"description": "Other resolvable persistent unique IDs related to the resource.",
|
310
|
+
"type": "array",
|
311
|
+
"items": {
|
312
|
+
"type": "object",
|
313
|
+
"properties": {
|
314
|
+
"id": {
|
315
|
+
"type": "string",
|
316
|
+
"format": "uri"
|
317
|
+
},
|
318
|
+
"type": {
|
319
|
+
"type": "string",
|
320
|
+
"enum": [
|
321
|
+
"IsNewVersionOf",
|
322
|
+
"IsPreviousVersionOf",
|
323
|
+
"IsVersionOf",
|
324
|
+
"HasVersion",
|
325
|
+
"IsPartOf",
|
326
|
+
"HasPart",
|
327
|
+
"IsVariantFormOf",
|
328
|
+
"IsOriginalFormOf",
|
329
|
+
"IsIdenticalTo",
|
330
|
+
"IsTranslationOf",
|
331
|
+
"HasTranslation",
|
332
|
+
"IsReviewedBy",
|
333
|
+
"Reviews",
|
334
|
+
"HasReview",
|
335
|
+
"IsPreprintOf",
|
336
|
+
"HasPreprint",
|
337
|
+
"IsSupplementTo",
|
338
|
+
"IsSupplementedBy"
|
339
|
+
]
|
340
|
+
}
|
341
|
+
},
|
342
|
+
"required": ["id", "type"]
|
343
|
+
},
|
344
|
+
"minItems": 1
|
345
|
+
},
|
346
|
+
"references": {
|
347
|
+
"type": "array",
|
348
|
+
"items": {
|
349
|
+
"type": "object",
|
350
|
+
"properties": {
|
351
|
+
"id": { "$ref": "#/definitions/id" },
|
352
|
+
"type": { "$ref": "#/definitions/type" },
|
353
|
+
"key": { "type": "string" },
|
354
|
+
"contributor": { "type": "string" },
|
355
|
+
"title": { "type": "string" },
|
356
|
+
"publisher": { "type": "string" },
|
357
|
+
"publicationYear": { "type": "string" },
|
358
|
+
"volume": { "type": "string" },
|
359
|
+
"issue": { "type": "string" },
|
360
|
+
"firstPage": { "type": "string" },
|
361
|
+
"lastPage": { "type": "string" },
|
362
|
+
"containerTitle": { "type": "string" },
|
363
|
+
"edition": { "type": "string" },
|
364
|
+
"unstructured": { "type": "string" }
|
365
|
+
},
|
366
|
+
"required": ["key"]
|
367
|
+
}
|
368
|
+
},
|
369
|
+
"subjects": {
|
370
|
+
"type": "array",
|
371
|
+
"items": {
|
372
|
+
"type": "object",
|
373
|
+
"properties": {
|
374
|
+
"subject": { "type": "string" },
|
375
|
+
"language": {
|
376
|
+
"description": "The language of the subject. Use one of the language codes from the IETF BCP 47 standard.",
|
377
|
+
"type": "string"
|
378
|
+
}
|
379
|
+
},
|
380
|
+
"required": ["subject"]
|
381
|
+
}
|
382
|
+
},
|
383
|
+
"titles": {
|
384
|
+
"description": "The titles of the resource.",
|
385
|
+
"type": "array",
|
386
|
+
"items": {
|
387
|
+
"type": "object",
|
388
|
+
"properties": {
|
389
|
+
"title": {
|
390
|
+
"description": "The title of the resource.",
|
391
|
+
"type": "string"
|
392
|
+
},
|
393
|
+
"type": {
|
394
|
+
"description": "The type of the title.",
|
395
|
+
"type": "string",
|
396
|
+
"enum": ["AlternativeTitle", "Subtitle", "TranslatedTitle"]
|
397
|
+
},
|
398
|
+
"language": {
|
399
|
+
"description": "The language of the title. Use one of the language codes from the IETF BCP 47 standard.",
|
400
|
+
"type": "string"
|
401
|
+
}
|
402
|
+
},
|
403
|
+
"required": ["title"]
|
404
|
+
}
|
405
|
+
},
|
406
|
+
"url": {
|
407
|
+
"description": "The URL of the resource.",
|
408
|
+
"type": "string",
|
409
|
+
"format": "uri"
|
410
|
+
},
|
411
|
+
"version": {
|
412
|
+
"description": "The version of the resource.",
|
413
|
+
"type": "string"
|
414
|
+
}
|
415
|
+
},
|
416
|
+
"required": ["id", "type"]
|
417
|
+
},
|
418
|
+
"contributorRole": {
|
419
|
+
"description": "The type of contribution made by a contributor",
|
420
|
+
"enum": [
|
421
|
+
"Author",
|
422
|
+
"Editor",
|
423
|
+
"Chair",
|
424
|
+
"Reviewer",
|
425
|
+
"ReviewAssistant",
|
426
|
+
"StatsReviewer",
|
427
|
+
"ReviewerExternal",
|
428
|
+
"Reader",
|
429
|
+
"Translator",
|
430
|
+
"ContactPerson",
|
431
|
+
"DataCollector",
|
432
|
+
"DataManager",
|
433
|
+
"Distributor",
|
434
|
+
"HostingInstitution",
|
435
|
+
"Producer",
|
436
|
+
"ProjectLeader",
|
437
|
+
"ProjectManager",
|
438
|
+
"ProjectMember",
|
439
|
+
"RegistrationAgency",
|
440
|
+
"RegistrationAuthority",
|
441
|
+
"RelatedPerson",
|
442
|
+
"ResearchGroup",
|
443
|
+
"RightsHolder",
|
444
|
+
"Researcher",
|
445
|
+
"Sponsor",
|
446
|
+
"WorkPackageLeader",
|
447
|
+
"Conceptualization",
|
448
|
+
"DataCuration",
|
449
|
+
"FormalAnalysis",
|
450
|
+
"FundingAcquisition",
|
451
|
+
"Investigation",
|
452
|
+
"Methodology",
|
453
|
+
"ProjectAdministration",
|
454
|
+
"Resources",
|
455
|
+
"Software",
|
456
|
+
"Supervision",
|
457
|
+
"Validation",
|
458
|
+
"Visualization",
|
459
|
+
"WritingOriginalDraft",
|
460
|
+
"WritingReviewEditing",
|
461
|
+
"Maintainer",
|
462
|
+
"Other"
|
463
|
+
],
|
464
|
+
"type": "string"
|
465
|
+
},
|
466
|
+
"geoLocationBox": {
|
467
|
+
"type": "object",
|
468
|
+
"properties": {
|
469
|
+
"westBoundLongitude": { "$ref": "#/definitions/longitude" },
|
470
|
+
"eastBoundLongitude": { "$ref": "#/definitions/longitude" },
|
471
|
+
"southBoundLatitude": { "$ref": "#/definitions/latitude" },
|
472
|
+
"northBoundLatitude": { "$ref": "#/definitions/latitude" }
|
473
|
+
}
|
474
|
+
},
|
475
|
+
"geoLocationPoint": {
|
476
|
+
"type": "object",
|
477
|
+
"properties": {
|
478
|
+
"pointLongitude": { "$ref": "#/definitions/longitude" },
|
479
|
+
"pointLatitude": { "$ref": "#/definitions/latitude" }
|
480
|
+
}
|
481
|
+
},
|
482
|
+
"id": {
|
483
|
+
"description": "The unique identifier for the resource.",
|
484
|
+
"type": "string",
|
485
|
+
"format": "uri"
|
486
|
+
},
|
487
|
+
"latitude": {
|
488
|
+
"type": "number",
|
489
|
+
"minimum": -90,
|
490
|
+
"maximum": 90
|
491
|
+
},
|
492
|
+
"longitude": {
|
493
|
+
"type": "number",
|
494
|
+
"minimum": -180,
|
495
|
+
"maximum": 180
|
496
|
+
},
|
497
|
+
"organization": {
|
498
|
+
"type": "object",
|
499
|
+
"properties": {
|
500
|
+
"id": {
|
501
|
+
"description": "The unique identifier for the organization.",
|
502
|
+
"type": "string",
|
503
|
+
"format": "uri"
|
504
|
+
},
|
505
|
+
"type": { "type": "string", "const": "Organization" },
|
506
|
+
"name": {
|
507
|
+
"description": "The name of the organization.",
|
508
|
+
"type": "string"
|
509
|
+
}
|
510
|
+
},
|
511
|
+
"required": ["name", "type"]
|
512
|
+
},
|
513
|
+
"person": {
|
514
|
+
"type": "object",
|
515
|
+
"properties": {
|
516
|
+
"id": { "type": "string", "format": "uri" },
|
517
|
+
"type": { "type": "string", "const": "Person" },
|
518
|
+
"givenName": {
|
519
|
+
"description": "The given name of the person.",
|
520
|
+
"type": "string"
|
521
|
+
},
|
522
|
+
"familyName": {
|
523
|
+
"description": "The family name of the person.",
|
524
|
+
"type": "string"
|
525
|
+
},
|
526
|
+
"affiliation": { "$ref": "#/definitions/affiliations" }
|
527
|
+
},
|
528
|
+
"required": ["familyName", "type"]
|
529
|
+
},
|
530
|
+
"type": {
|
531
|
+
"type": "string",
|
532
|
+
"enum": [
|
533
|
+
"Article",
|
534
|
+
"Audiovisual",
|
535
|
+
"BookChapter",
|
536
|
+
"BookPart",
|
537
|
+
"BookSection",
|
538
|
+
"BookSeries",
|
539
|
+
"BookSet",
|
540
|
+
"Book",
|
541
|
+
"Collection",
|
542
|
+
"Component",
|
543
|
+
"Database",
|
544
|
+
"Dataset",
|
545
|
+
"Dissertation",
|
546
|
+
"Document",
|
547
|
+
"Entry",
|
548
|
+
"Event",
|
549
|
+
"Grant",
|
550
|
+
"Image",
|
551
|
+
"Instrument",
|
552
|
+
"InteractiveResource",
|
553
|
+
"JournalArticle",
|
554
|
+
"JournalIssue",
|
555
|
+
"JournalVolume",
|
556
|
+
"Journal",
|
557
|
+
"PeerReview",
|
558
|
+
"PhysicalObject",
|
559
|
+
"Presentation",
|
560
|
+
"ProceedingsArticle",
|
561
|
+
"ProceedingsSeries",
|
562
|
+
"Proceedings",
|
563
|
+
"ReportComponent",
|
564
|
+
"ReportSeries",
|
565
|
+
"Report",
|
566
|
+
"Software",
|
567
|
+
"Standard",
|
568
|
+
"StudyRegistration",
|
569
|
+
"WebPage",
|
570
|
+
"Other"
|
571
|
+
]
|
572
|
+
}
|
573
|
+
}
|
574
|
+
}
|
commonmeta/schema_utils.py
CHANGED
@@ -7,7 +7,7 @@ from jsonschema import Draft202012Validator, ValidationError
|
|
7
7
|
def json_schema_errors(instance, schema: str = "commonmeta"):
|
8
8
|
"""validate against JSON schema"""
|
9
9
|
schema_map = {
|
10
|
-
"commonmeta": "commonmeta_v0.
|
10
|
+
"commonmeta": "commonmeta_v0.15",
|
11
11
|
"datacite": "datacite-v4.5",
|
12
12
|
"crossref": "crossref-v0.2",
|
13
13
|
"csl": "csl-data",
|
@@ -41,8 +41,6 @@ def write_inveniordm(metadata):
|
|
41
41
|
for i in wrap(metadata.identifiers)
|
42
42
|
if i.get("id", None) != metadata.id
|
43
43
|
]
|
44
|
-
print(metadata.references)
|
45
|
-
print(metadata.relations)
|
46
44
|
references = [
|
47
45
|
to_inveniordm_related_identifier(i)
|
48
46
|
for i in wrap(metadata.references)
|
@@ -225,17 +223,18 @@ def to_inveniordm_related_identifier(relation: dict) -> dict:
|
|
225
223
|
scheme = "url"
|
226
224
|
|
227
225
|
# normalize relation types
|
226
|
+
relation_type = relation.get("type")
|
228
227
|
if relation.get("type", None) is None:
|
229
|
-
|
228
|
+
relation_type = "References"
|
230
229
|
if relation.get("type") == "HasReview":
|
231
|
-
|
232
|
-
|
230
|
+
relation_type = "IsReviewedBy"
|
231
|
+
|
233
232
|
return compact(
|
234
233
|
{
|
235
234
|
"identifier": identifier,
|
236
235
|
"scheme": scheme,
|
237
236
|
"relation_type": {
|
238
|
-
"id": relation_type,
|
237
|
+
"id": relation_type.lower(),
|
239
238
|
},
|
240
239
|
}
|
241
240
|
)
|
@@ -244,7 +243,7 @@ def to_inveniordm_related_identifier(relation: dict) -> dict:
|
|
244
243
|
def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
245
244
|
"""Convert funding to inveniordm funding"""
|
246
245
|
if funding.get("funderIdentifierType", None) == "ROR":
|
247
|
-
funder_identifier = id_from_url(
|
246
|
+
funder_identifier = id_from_url(funding.get("funderIdentifier", None))
|
248
247
|
elif funding.get("funderIdentifierType", None) == "Crossref Funder ID":
|
249
248
|
# convert to ROR
|
250
249
|
funder_identifier = id_from_url(
|
@@ -254,30 +253,43 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
|
254
253
|
)
|
255
254
|
else:
|
256
255
|
funder_identifier = None
|
256
|
+
award_number = funding.get("awardNumber", None)
|
257
257
|
award_title = funding.get("awardTitle", None)
|
258
258
|
if award_title:
|
259
259
|
award_title = {"title": {"en": award_title}}
|
260
260
|
if funding.get("awardUri", None):
|
261
|
+
award_identifier = funding.get("awardUri", None)
|
262
|
+
scheme = "doi" if normalize_doi(award_identifier) else "url"
|
263
|
+
if scheme == "doi":
|
264
|
+
award_identifier = doi_from_url(award_identifier)
|
261
265
|
award_identifiers = [
|
262
266
|
{
|
263
|
-
"scheme":
|
264
|
-
"identifier":
|
267
|
+
"scheme": scheme,
|
268
|
+
"identifier": award_identifier,
|
265
269
|
},
|
266
270
|
]
|
267
271
|
else:
|
268
272
|
award_identifiers = None
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
273
|
+
|
274
|
+
if award_number or award_title or award_identifiers:
|
275
|
+
return compact(
|
276
|
+
{
|
277
|
+
"funder": compact(
|
278
|
+
{
|
279
|
+
"name": funding.get("funderName"),
|
280
|
+
"id": funder_identifier,
|
281
|
+
}
|
282
|
+
),
|
283
|
+
"award": compact(
|
284
|
+
{
|
285
|
+
"number": award_number,
|
286
|
+
"title": award_title,
|
287
|
+
"identifiers": award_identifiers,
|
288
|
+
}
|
289
|
+
),
|
290
|
+
}
|
278
291
|
)
|
279
|
-
|
280
|
-
award = None
|
292
|
+
|
281
293
|
return compact(
|
282
294
|
{
|
283
295
|
"funder": compact(
|
@@ -286,6 +298,5 @@ def to_inveniordm_funding(funding: dict) -> Optional[dict]:
|
|
286
298
|
"id": funder_identifier,
|
287
299
|
}
|
288
300
|
),
|
289
|
-
"award": award,
|
290
301
|
}
|
291
302
|
)
|
@@ -1,10 +1,10 @@
|
|
1
|
-
commonmeta/__init__.py,sha256=
|
1
|
+
commonmeta/__init__.py,sha256=Xc4MVM80sSD7NZdUZZB6CqIuzR5xxY7Fy-dFmKTeNqI,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=
|
7
|
-
commonmeta/crossref_utils.py,sha256=
|
6
|
+
commonmeta/constants.py,sha256=cank4niDCO-VvjjRIgCxOAqFEnV1R8xyGC6xEL1iDsw,17461
|
7
|
+
commonmeta/crossref_utils.py,sha256=LBYfmhIldYryaBUYohfLnv870aWGMDm043Ny8Wav6Bg,22370
|
8
8
|
commonmeta/date_utils.py,sha256=amF3E0ZJlh8yY5eY3aVXQyAO1x2WuZHJXw-ajOEcdUQ,5808
|
9
9
|
commonmeta/doi_utils.py,sha256=Dt6K9ADD2ga2WNsOzfX9f29gnubhn7xqeKL7U5pEpBs,8209
|
10
10
|
commonmeta/metadata.py,sha256=dqqk4IW-_OwtS_PVs0i7AuxrkNqOYjJCqhQJ2X-I1DQ,12398
|
@@ -18,15 +18,16 @@ commonmeta/readers/crossref_xml_reader.py,sha256=QF1A-r3OJbykBTH9YMSxusT3-KSKmmz
|
|
18
18
|
commonmeta/readers/csl_reader.py,sha256=5V_sHSJwcAWJmhB8SYk199nB96BWYX1Sq9vkQ3iEmAY,3164
|
19
19
|
commonmeta/readers/datacite_reader.py,sha256=CdOtxhthrakBoQMsLTdPx6sUCmqtEWo5ICYE6ZsWDdo,12026
|
20
20
|
commonmeta/readers/datacite_xml_reader.py,sha256=nhnO92fZihr1HZlbXjyem-HJXc9_DWLgJ2zeltuPMIg,13041
|
21
|
-
commonmeta/readers/inveniordm_reader.py,sha256=
|
22
|
-
commonmeta/readers/json_feed_reader.py,sha256=
|
23
|
-
commonmeta/readers/kbase_reader.py,sha256=
|
21
|
+
commonmeta/readers/inveniordm_reader.py,sha256=jzv0rXzT8OCdPD_MShBXTnlwD-F9tpTX7OKZGn8smzs,7480
|
22
|
+
commonmeta/readers/json_feed_reader.py,sha256=y-sX_l9AD0I71pSZSZWr2x2tLTlD4mxoB2eF0vf0rWk,13034
|
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
|
26
26
|
commonmeta/resources/cff_v1.2.0.json,sha256=MpfjDYgX7fN9PLiG54ISZ2uu9WItNqfh-yaRuTf6Ptg,46691
|
27
27
|
commonmeta/resources/commonmeta_v0.12.json,sha256=HUSNReXh2JN3Q6YWSt7CE69js8dh50OlpMYGTyU98oU,16762
|
28
28
|
commonmeta/resources/commonmeta_v0.13.json,sha256=2-WSZGijR13zVu97S_YHXr-cyeLW7hzHXYMlr6nIjdw,15787
|
29
29
|
commonmeta/resources/commonmeta_v0.14.json,sha256=nACmkTe4IrZkygd5AeJnAv9P4EWfzCwW9oL5AhubvnE,17657
|
30
|
+
commonmeta/resources/commonmeta_v0.15.json,sha256=tOc1QL2n9HYngEgxIZDwBFWEXxX1bd2wtOqCqI0usnw,17707
|
30
31
|
commonmeta/resources/crossref/AccessIndicators.xsd,sha256=en-G2FFt4ewIFRw5C6g4YA8Nc0M66fCM2CygiO_ZqqY,2825
|
31
32
|
commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3-elements.xsd,sha256=l5jJMFm4xx09bavH2Gc3EqIdr-0PTf6M9YBTNpUaZhY,415409
|
32
33
|
commonmeta/resources/crossref/JATS-journalpublishing1-3d2-mathml3.xsd,sha256=goO2ckm12fF2-kGFZC_FaTBdi4BK3YCRwb_ESur8dfY,2210
|
@@ -55,7 +56,7 @@ commonmeta/resources/styles/harvard-cite-them-right.csl,sha256=XmLVFDrfsgkECYaAb
|
|
55
56
|
commonmeta/resources/styles/ieee.csl,sha256=DfuN__z8FZ5Rcdaj_Myc5y_FmB-fHwfRVTeS9-hOgmQ,15854
|
56
57
|
commonmeta/resources/styles/modern-language-association.csl,sha256=HI2iU4krze1aHYc9VSQCUyw_2I6fEQYnA9xIWo-xNus,11594
|
57
58
|
commonmeta/resources/styles/vancouver.csl,sha256=lun3_i2oTilgsANk4LjFao2UDPQlGj_hgFgKAWC_DF8,12878
|
58
|
-
commonmeta/schema_utils.py,sha256=
|
59
|
+
commonmeta/schema_utils.py,sha256=gg3l1jd_lFtRkQlO1DYGMVbC10nEmVTN4AWacxC4AAE,915
|
59
60
|
commonmeta/translators.py,sha256=RpGJtKNLjmz41VREZDY7KyyE2eXOi8j7m-da4jHmknI,1362
|
60
61
|
commonmeta/utils.py,sha256=dblEYOmR0q6qZgsqnQOunm_Zj7YP4bugzwK1ps5SYq8,42583
|
61
62
|
commonmeta/writers/__init__.py,sha256=47-snms6xBHkoEXKYV1DBtH1npAtlVtvY29Z4Zr45qI,45
|
@@ -65,11 +66,11 @@ commonmeta/writers/commonmeta_writer.py,sha256=2qlttCfYpGhfVjrYkjzbIra7AywssRLT3
|
|
65
66
|
commonmeta/writers/crossref_xml_writer.py,sha256=0Ds494RnXfdfjWw5CLX1kwV2zP7gqffdVqO-X74Uc6c,492
|
66
67
|
commonmeta/writers/csl_writer.py,sha256=rlCeShkvC6ui9By0yVfNCMay_JfaZ4AooUPOPg-g-2M,2819
|
67
68
|
commonmeta/writers/datacite_writer.py,sha256=G7Lr0aZ4sAEdbfXe3dG4Y6AyGUKA9UWr_iiaQRDnV24,6233
|
68
|
-
commonmeta/writers/inveniordm_writer.py,sha256=
|
69
|
+
commonmeta/writers/inveniordm_writer.py,sha256=sCDmPC4DEOWjuKtA14dZhjrr--IiO0rgeTXL2O2hre4,9642
|
69
70
|
commonmeta/writers/ris_writer.py,sha256=AcnCszS3WY9lF594NbFBtLylsA8ownnYp_XLQJ84Ios,2093
|
70
71
|
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.
|
72
|
+
commonmeta_py-0.40.dist-info/LICENSE,sha256=746hEF2wZCKkcckk5-_DcBLtHewfaEMS4iXTlA1PVwk,1074
|
73
|
+
commonmeta_py-0.40.dist-info/METADATA,sha256=bB20Im9gNUUGJIt7TnMLFpGouHdnpmV7GkC_fiZmk7I,8331
|
74
|
+
commonmeta_py-0.40.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
75
|
+
commonmeta_py-0.40.dist-info/entry_points.txt,sha256=vbcDw3_2lMTKdcAL2VUF4DRYRpKuzXVYLMCdgKVf88U,49
|
76
|
+
commonmeta_py-0.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|