oarepo-runtime 2.0.0.dev40__tar.gz → 2.0.0.dev42__tar.gz
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.
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/PKG-INFO +1 -1
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/__init__.py +1 -1
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/resources/signposting/__init__.py +37 -42
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/.gitignore +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/LICENSE +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/README.md +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/api.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/cli/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/cli/search.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/config.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/ext.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/info/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/info/views.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/proxies.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/py.typed +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/drafts.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/mapping.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/pid_providers.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/base.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/custom_fields.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/mapping.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/publication_status.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/relations.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/systemfields/selectors.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/resources/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/resources/config.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/config/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/config/components.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/config/link_conditions.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/config/permissions.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/base.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/date.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/nested_facet.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/params.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/utils.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/generators.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/custom_fields.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/links.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/mapping.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/results.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/__init__.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/i18n.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/ui.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/typing.py +0 -0
- {oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/pyproject.toml +0 -0
|
@@ -30,15 +30,12 @@ describedby <-> describes
|
|
|
30
30
|
from __future__ import annotations
|
|
31
31
|
|
|
32
32
|
from collections import defaultdict
|
|
33
|
-
from typing import
|
|
33
|
+
from typing import Any, Literal, cast, overload
|
|
34
34
|
from urllib.parse import urljoin
|
|
35
35
|
|
|
36
|
-
if TYPE_CHECKING:
|
|
37
|
-
from invenio_records_resources.services.records.results import RecordItem
|
|
38
36
|
from signposting import AbsoluteURI, LinkRel, Signpost
|
|
39
37
|
|
|
40
38
|
from oarepo_runtime.proxies import current_runtime
|
|
41
|
-
from oarepo_runtime.typing import record_from_result
|
|
42
39
|
|
|
43
40
|
|
|
44
41
|
def signpost_link_to_str(signpost_link: Signpost) -> str:
|
|
@@ -152,21 +149,21 @@ def list_of_signpost_links_to_http_header(links_list: list[Signpost]) -> str:
|
|
|
152
149
|
return f"Link: {', '.join(links)}"
|
|
153
150
|
|
|
154
151
|
|
|
155
|
-
def create_linkset(datacite_dict: dict,
|
|
152
|
+
def create_linkset(datacite_dict: dict, record_dict: dict) -> str:
|
|
156
153
|
"""Create a linkset for the record item in the application/linkset format.
|
|
157
154
|
|
|
158
155
|
Args:
|
|
159
156
|
datacite_dict: dictionary with datacite data
|
|
160
|
-
|
|
157
|
+
record_dict: record item dict, for which signpost links should be generated
|
|
161
158
|
|
|
162
159
|
Returns: linkset in string format
|
|
163
160
|
|
|
164
161
|
"""
|
|
165
|
-
landing_page_url =
|
|
162
|
+
landing_page_url = record_dict.get("links", {}).get("self_html")
|
|
166
163
|
# just sanity check, we don't expect this to happen, not covered in tests
|
|
167
164
|
if not landing_page_url: # pragma: no cover
|
|
168
165
|
return ""
|
|
169
|
-
landing_page_links = landing_page_signpost_links_list(datacite_dict,
|
|
166
|
+
landing_page_links = landing_page_signpost_links_list(datacite_dict, record_dict, short=False)
|
|
170
167
|
additional_links: list[Signpost] = get_additional_links(landing_page_links, landing_page_url, as_dict=False)
|
|
171
168
|
anchored_links = [
|
|
172
169
|
anchor_signpost_link(signpost_link, landing_page_url) for signpost_link in landing_page_links
|
|
@@ -175,21 +172,21 @@ def create_linkset(datacite_dict: dict, record_item: RecordItem) -> str:
|
|
|
175
172
|
return ", ".join(links)
|
|
176
173
|
|
|
177
174
|
|
|
178
|
-
def create_linkset_json(datacite_dict: dict,
|
|
175
|
+
def create_linkset_json(datacite_dict: dict, record_dict: dict) -> dict[str, list[dict[str, Any]]]:
|
|
179
176
|
"""Create a linkset for the record item in the application/linkset+json format.
|
|
180
177
|
|
|
181
178
|
Args:
|
|
182
179
|
datacite_dict: dictionary with datacite data
|
|
183
|
-
|
|
180
|
+
record_dict: record item dict, for which signpost links should be generated
|
|
184
181
|
|
|
185
182
|
Returns: linkset in JSON format
|
|
186
183
|
|
|
187
184
|
"""
|
|
188
|
-
landing_page_url =
|
|
185
|
+
landing_page_url = record_dict.get("links", {}).get("self_html")
|
|
189
186
|
# just sanity check, we don't expect this to happen, not covered in tests
|
|
190
187
|
if not landing_page_url: # pragma: no cover
|
|
191
188
|
return {}
|
|
192
|
-
landing_page_links = landing_page_signpost_links_list(datacite_dict,
|
|
189
|
+
landing_page_links = landing_page_signpost_links_list(datacite_dict, record_dict, short=False)
|
|
193
190
|
dict_of_links_by_relation = defaultdict(list)
|
|
194
191
|
for link in landing_page_links:
|
|
195
192
|
dict_of_links_by_relation[str(link.rel)].append(link)
|
|
@@ -204,18 +201,17 @@ def create_linkset_json(datacite_dict: dict, record_item: RecordItem) -> dict[st
|
|
|
204
201
|
return {"linkset": [dict(links_json), *[x for x in additional_links if x]]}
|
|
205
202
|
|
|
206
203
|
|
|
207
|
-
def file_content_signpost_links_list(
|
|
204
|
+
def file_content_signpost_links_list(record_dict: dict) -> list[Signpost]:
|
|
208
205
|
"""Create a list of signpost links for the file content of the record item.
|
|
209
206
|
|
|
210
207
|
Args:
|
|
211
|
-
|
|
208
|
+
record_dict: record item dict with the file to generate a signpost link for
|
|
212
209
|
|
|
213
210
|
Returns: list with the signpost link for the file content
|
|
214
211
|
|
|
215
212
|
"""
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
landing_page_url = model.ui_url(view_name="record_detail", pid_value=record.pid.pid_value)
|
|
213
|
+
model = current_runtime.models_by_schema[record_dict["$schema"]]
|
|
214
|
+
landing_page_url = model.ui_url(view_name="record_detail", pid_value=record_dict["id"])
|
|
219
215
|
if not landing_page_url: # pragma: no cover
|
|
220
216
|
return []
|
|
221
217
|
return [
|
|
@@ -237,47 +233,48 @@ def file_content_signpost_links_list(record_item: RecordItem) -> list[Signpost]:
|
|
|
237
233
|
]
|
|
238
234
|
|
|
239
235
|
|
|
240
|
-
def export_format_signpost_links_list(
|
|
236
|
+
def export_format_signpost_links_list(record_dict: dict) -> list[Signpost]:
|
|
241
237
|
"""Create a list of signpost links for the export format of the record item.
|
|
242
238
|
|
|
243
239
|
Args:
|
|
244
|
-
|
|
240
|
+
record_dict: record item dict with the export format to generate a signpost link for
|
|
245
241
|
code: code of the export format
|
|
246
242
|
|
|
247
243
|
Returns: list with the signpost link for the export format
|
|
248
244
|
|
|
249
245
|
"""
|
|
246
|
+
landing_page_url = record_dict.get("links", {}).get("self_html")
|
|
247
|
+
if not landing_page_url: # pragma: no cover
|
|
248
|
+
return []
|
|
250
249
|
return [
|
|
251
250
|
Signpost(
|
|
252
251
|
rel=LinkRel.linkset,
|
|
253
|
-
target=
|
|
252
|
+
target=landing_page_url,
|
|
254
253
|
media_type="application/linkset",
|
|
255
254
|
),
|
|
256
255
|
Signpost(
|
|
257
256
|
rel=LinkRel.linkset,
|
|
258
|
-
target=
|
|
257
|
+
target=landing_page_url,
|
|
259
258
|
media_type="application/linkset+json",
|
|
260
259
|
),
|
|
261
|
-
Signpost(rel=LinkRel.describes, target=
|
|
260
|
+
Signpost(rel=LinkRel.describes, target=landing_page_url, media_type="text/html"),
|
|
262
261
|
]
|
|
263
262
|
|
|
264
263
|
|
|
265
|
-
def landing_page_signpost_links_list(datacite_dict: dict,
|
|
264
|
+
def landing_page_signpost_links_list(datacite_dict: dict, record_dict: dict, short: bool) -> list[Signpost]:
|
|
266
265
|
"""Create a list of signpost links for the landing page of the record item.
|
|
267
266
|
|
|
268
267
|
Args:
|
|
269
268
|
datacite_dict: dictionary with datacite data
|
|
270
|
-
|
|
269
|
+
record_dict: record item dict, for which signpost links should be generated
|
|
271
270
|
short: If true, lists only the first three links for relations with greater count
|
|
272
271
|
|
|
273
272
|
Returns: list of signpost links for the landing page
|
|
274
273
|
|
|
275
274
|
"""
|
|
276
275
|
signposting_links: list[Signpost] = []
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
record_files = record_data.get("files", {}).get("entries", {})
|
|
280
|
-
model = current_runtime.get_model_for_record(record)
|
|
276
|
+
record_files = record_dict.get("files", {}).get("entries", {})
|
|
277
|
+
model = current_runtime.models_by_schema[record_dict["$schema"]]
|
|
281
278
|
|
|
282
279
|
# author - prvni tri
|
|
283
280
|
data = datacite_dict["data"]
|
|
@@ -297,7 +294,7 @@ def landing_page_signpost_links_list(datacite_dict: dict, record_item: RecordIte
|
|
|
297
294
|
# describedby
|
|
298
295
|
for model_export in model.exports:
|
|
299
296
|
model_export_url = model.ui_url(
|
|
300
|
-
view_name="
|
|
297
|
+
view_name="record_export", pid_value=record_dict["id"], export_format=model_export.code
|
|
301
298
|
)
|
|
302
299
|
# just sanity check, we don't expect this to happen, not covered in tests
|
|
303
300
|
if not model_export_url: # pragma: no cover
|
|
@@ -310,7 +307,7 @@ def landing_page_signpost_links_list(datacite_dict: dict, record_item: RecordIte
|
|
|
310
307
|
record_file_values = record_files.values()
|
|
311
308
|
if short:
|
|
312
309
|
record_file_values = list(record_file_values)[:3]
|
|
313
|
-
record_files_url =
|
|
310
|
+
record_files_url = record_dict.get("links", {}).get("files")
|
|
314
311
|
if record_files_url:
|
|
315
312
|
signposting_links.extend(
|
|
316
313
|
Signpost(
|
|
@@ -343,23 +340,21 @@ def landing_page_signpost_links_list(datacite_dict: dict, record_item: RecordIte
|
|
|
343
340
|
return signposting_links
|
|
344
341
|
|
|
345
342
|
|
|
346
|
-
def
|
|
347
|
-
"""Create a linkset from the record item. Get datacite to build linkset from model exports."""
|
|
348
|
-
|
|
349
|
-
model = current_runtime.get_model_for_record(record)
|
|
343
|
+
def record_dict_to_linkset(record_dict: dict) -> str:
|
|
344
|
+
"""Create a linkset from the dictionary of a record item. Get datacite to build linkset from model exports."""
|
|
345
|
+
model = current_runtime.models_by_schema[record_dict["$schema"]]
|
|
350
346
|
datacite_export = model.get_export_by_mimetype("application/vnd.datacite.datacite+json")
|
|
351
347
|
if not datacite_export:
|
|
352
348
|
return ""
|
|
353
|
-
datacite_dict = datacite_export.serializer.serialize_object(
|
|
354
|
-
return create_linkset(datacite_dict,
|
|
349
|
+
datacite_dict = datacite_export.serializer.serialize_object(record_dict)
|
|
350
|
+
return create_linkset(datacite_dict, record_dict)
|
|
355
351
|
|
|
356
352
|
|
|
357
|
-
def
|
|
358
|
-
"""Create a JSON linkset from the record item. Get datacite to build linkset from model exports."""
|
|
359
|
-
|
|
360
|
-
model = current_runtime.get_model_for_record(record)
|
|
353
|
+
def record_dict_to_json_linkset(record_dict: dict) -> dict[str, list[dict[str, Any]]]:
|
|
354
|
+
"""Create a JSON linkset from the dictionary of a record item. Get datacite to build linkset from model exports."""
|
|
355
|
+
model = current_runtime.models_by_schema[record_dict["$schema"]]
|
|
361
356
|
datacite_export = model.get_export_by_mimetype("application/vnd.datacite.datacite+json")
|
|
362
357
|
if not datacite_export:
|
|
363
358
|
return {}
|
|
364
|
-
datacite_dict = datacite_export.serializer.serialize_object(
|
|
365
|
-
return create_linkset_json(datacite_dict,
|
|
359
|
+
datacite_dict = datacite_export.serializer.serialize_object(record_dict)
|
|
360
|
+
return create_linkset_json(datacite_dict, record_dict)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/records/pid_providers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/resources/__init__.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/resources/config.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/__init__.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/config/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/__init__.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/base.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/date.py
RENAMED
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/params.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/facets/utils.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/generators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/links.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/records/mapping.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/results.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/__init__.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/i18n.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/i18n_ui.py
RENAMED
|
File without changes
|
{oarepo_runtime-2.0.0.dev40 → oarepo_runtime-2.0.0.dev42}/oarepo_runtime/services/schema/ui.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|