oarepo-runtime 1.5.11__tar.gz → 1.5.13__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {oarepo-runtime-1.5.11/oarepo_runtime.egg-info → oarepo-runtime-1.5.13}/PKG-INFO +1 -1
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/__init__.py +6 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/mapping.py +0 -2
- oarepo-runtime-1.5.13/oarepo_runtime/records/systemfields/selectors.py +38 -0
- oarepo-runtime-1.5.13/oarepo_runtime/records/systemfields/synthetic.py +111 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/config/service.py +5 -4
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/results.py +0 -1
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/utils/functools.py +2 -2
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13/oarepo_runtime.egg-info}/PKG-INFO +1 -1
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/SOURCES.txt +1 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/setup.cfg +1 -1
- oarepo-runtime-1.5.11/oarepo_runtime/records/systemfields/synthetic.py +0 -79
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/LICENSE +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/MANIFEST.in +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/README.md +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/assets.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/base.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/cf.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/check.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/configuration.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/fixtures.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/index.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/cli/validate.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/asynchronous.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/catalogue.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/datastreams.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/errors.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/ext.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/fixtures.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/json.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/attachments.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/excel.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/json.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/service.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/semi_asynchronous.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/synchronous.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/transformers.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/types.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/utils.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/attachments_file.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/attachments_service.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/service.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/utils.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/validation_errors.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/ext.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/ext_config.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/i18n/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/info/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/info/views.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/profile.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/proxies.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/dumpers/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/dumpers/edtf_interval.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/entity_resolvers/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/entity_resolvers/proxies.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/base.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/internal.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/lookup.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/pid_relation.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/featured_file.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/has_draftcheck.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/icu.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/record_status.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/resources/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/resources/file_resource.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/resources/localized_ui_json_serializer.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/config/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/config/permissions_presets.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/custom_fields/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/custom_fields/mappings.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/expansions/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/expansions/expandable_fields.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/expansions/service.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/base.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/date.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/enum.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/facet_groups_names.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/max_facet.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/nested_facet.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/params.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/files/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/files/service.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/components.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/errors.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/mapping.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/cf.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/i18n.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/i18n_ui.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/i18n_validation.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/marshmallow.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/polymorphic.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/ui.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/validation.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/search.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/default_translations.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/jinjax_messages.jinja +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/messages.pot +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/uow.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/utils/__init__.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/utils/path.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/entry_points.txt +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/requires.txt +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/top_level.txt +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/pyproject.toml +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/setup.py +0 -0
- {oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/tests/pkg_data/__init__.py +0 -0
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/__init__.py
RENAMED
@@ -1,5 +1,7 @@
|
|
1
1
|
from .icu import ICUField, ICUSortField, ICUSuggestField
|
2
2
|
from .mapping import MappingSystemFieldMixin, SystemFieldDumperExt
|
3
|
+
from .selectors import FirstItemSelector, PathSelector, Selector
|
4
|
+
from .synthetic import SyntheticSystemField
|
3
5
|
|
4
6
|
__all__ = (
|
5
7
|
"ICUField",
|
@@ -7,4 +9,8 @@ __all__ = (
|
|
7
9
|
"ICUSortField",
|
8
10
|
"MappingSystemFieldMixin",
|
9
11
|
"SystemFieldDumperExt",
|
12
|
+
"SyntheticSystemField",
|
13
|
+
"PathSelector",
|
14
|
+
"Selector",
|
15
|
+
"FirstItemSelector",
|
10
16
|
)
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/mapping.py
RENAMED
@@ -19,12 +19,10 @@ class MappingSystemFieldMixin:
|
|
19
19
|
@classmethod
|
20
20
|
def search_dump(cls, data, record):
|
21
21
|
"""Dump custom field."""
|
22
|
-
pass
|
23
22
|
|
24
23
|
@classmethod
|
25
24
|
def search_load(cls, data, record_cls):
|
26
25
|
"""Load custom field."""
|
27
|
-
pass
|
28
26
|
|
29
27
|
|
30
28
|
class SystemFieldDumperExt(SearchDumperExt):
|
@@ -0,0 +1,38 @@
|
|
1
|
+
from typing import List
|
2
|
+
|
3
|
+
|
4
|
+
class Selector:
|
5
|
+
def select(self, record):
|
6
|
+
return []
|
7
|
+
|
8
|
+
|
9
|
+
class PathSelector:
|
10
|
+
def __init__(self, *paths):
|
11
|
+
self.paths = [x.split(".") for x in paths]
|
12
|
+
|
13
|
+
def select(self, record):
|
14
|
+
ret = []
|
15
|
+
for path in self.paths:
|
16
|
+
for rec in getter(record, path):
|
17
|
+
ret.append(rec)
|
18
|
+
return ret
|
19
|
+
|
20
|
+
|
21
|
+
class FirstItemSelector(PathSelector):
|
22
|
+
def select(self, record):
|
23
|
+
for rec in super().select(record):
|
24
|
+
return [rec]
|
25
|
+
|
26
|
+
|
27
|
+
def getter(data, path: List):
|
28
|
+
if len(path) == 0:
|
29
|
+
if isinstance(data, list):
|
30
|
+
yield from data
|
31
|
+
else:
|
32
|
+
yield data
|
33
|
+
elif isinstance(data, dict):
|
34
|
+
if path[0] in data:
|
35
|
+
yield from getter(data[path[0]], path[1:])
|
36
|
+
elif isinstance(data, list):
|
37
|
+
for item in data:
|
38
|
+
yield from getter(item, path)
|
@@ -0,0 +1,111 @@
|
|
1
|
+
from invenio_records.systemfields import SystemField
|
2
|
+
|
3
|
+
from .mapping import MappingSystemFieldMixin
|
4
|
+
|
5
|
+
|
6
|
+
class SyntheticSystemField(MappingSystemFieldMixin, SystemField):
|
7
|
+
"""
|
8
|
+
A class that provides a synthetic system field, that is a system field that
|
9
|
+
generates its content from what is already present inside the record.
|
10
|
+
|
11
|
+
The field is not stored in the record, but is generated on the fly when
|
12
|
+
the record is being indexed.
|
13
|
+
|
14
|
+
Usage:
|
15
|
+
1. Check if any of the provided selectors (oarepo_runtime.records.systemfields.selectors)
|
16
|
+
are usable for your use case. If not, create a subclass of Selector class.
|
17
|
+
2. Put this class onto the record. If you use oarepo-model-builder, add it to the model
|
18
|
+
like:
|
19
|
+
```yaml
|
20
|
+
record:
|
21
|
+
record:
|
22
|
+
imports:
|
23
|
+
- oarepo_runtime.records.systemfields.SyntheticSystemField
|
24
|
+
- oarepo_vocabularies.records.selectors.LevelSelector
|
25
|
+
fields:
|
26
|
+
faculty = SyntheticSystemField(selector=LevelSelector("metadata.thesis.degreeGrantors", level=1))
|
27
|
+
department = SyntheticSystemField(selector=LevelSelector("metadata.thesis.degreeGrantors", level=2))
|
28
|
+
defenseYear = |
|
29
|
+
SyntheticSystemField(selector=PathSelector("metadata.thesis.dateDefended"),
|
30
|
+
transformer=lambda x: x[:4]
|
31
|
+
)
|
32
|
+
```
|
33
|
+
|
34
|
+
4. Add the extra fields to the mapping and facets. If using oarepo-model-builder, add it to the
|
35
|
+
model like the following piece of code and compile the model:
|
36
|
+
```yaml
|
37
|
+
record:
|
38
|
+
properties:
|
39
|
+
faculty:
|
40
|
+
type: vocabulary
|
41
|
+
vocabulary-type: institutions
|
42
|
+
facets:
|
43
|
+
facet-groups:
|
44
|
+
- default
|
45
|
+
label.cs: Fakulta
|
46
|
+
label.en: Faculty
|
47
|
+
|
48
|
+
|
49
|
+
department:
|
50
|
+
type: vocabulary
|
51
|
+
vocabulary-type: institutions
|
52
|
+
facets:
|
53
|
+
facet-groups:
|
54
|
+
- default
|
55
|
+
label.cs: Ústav
|
56
|
+
label.en: Department
|
57
|
+
|
58
|
+
defenseYear:
|
59
|
+
type: integer
|
60
|
+
facets:
|
61
|
+
facet-groups:
|
62
|
+
- default
|
63
|
+
label.cs: Rok obhajoby
|
64
|
+
label.en: Defense year
|
65
|
+
```
|
66
|
+
"""
|
67
|
+
|
68
|
+
def __init__(self, selector=None, filter=None, map=None, key=None, **kwargs):
|
69
|
+
self.selector = selector
|
70
|
+
self.map = map
|
71
|
+
self.filter = filter
|
72
|
+
super().__init__(key=key, **kwargs)
|
73
|
+
|
74
|
+
def search_dump(self, data, record):
|
75
|
+
dt = self._value(data)
|
76
|
+
if dt:
|
77
|
+
key = self.key.split(".")
|
78
|
+
d = data
|
79
|
+
for k in key[:-1]:
|
80
|
+
d = d.setdefault(k, {})
|
81
|
+
d[key[-1]] = dt
|
82
|
+
|
83
|
+
def search_load(self, data, record_cls):
|
84
|
+
def remove_key(d, key):
|
85
|
+
if len(key) == 1:
|
86
|
+
d.pop(key[0], None)
|
87
|
+
else:
|
88
|
+
if not isinstance(d, dict) or key[0] not in d:
|
89
|
+
return
|
90
|
+
remove_key(d[key[0]], key[1:])
|
91
|
+
if not d[key[0]]:
|
92
|
+
d.pop(key[0])
|
93
|
+
remove_key(data, self.key.split("."))
|
94
|
+
|
95
|
+
def __get__(self, record, owner=None):
|
96
|
+
if record is None:
|
97
|
+
return self
|
98
|
+
return self._value(record)
|
99
|
+
|
100
|
+
def _value(self, data):
|
101
|
+
if self.selector:
|
102
|
+
value = list(self.selector.select(data))
|
103
|
+
if self.filter:
|
104
|
+
value = [x for x in value if self.filter(x)]
|
105
|
+
if self.map:
|
106
|
+
value = [self.map(x) for x in value]
|
107
|
+
value = [x for x in value if x is not None]
|
108
|
+
return value
|
109
|
+
raise ValueError(
|
110
|
+
"Please either provide a selector or subclass this class and implement a _value method"
|
111
|
+
)
|
@@ -54,8 +54,7 @@ class PermissionsPresetsConfigMixin:
|
|
54
54
|
"""
|
55
55
|
registered_preset_classes = current_app.config["OAREPO_PERMISSIONS_PRESETS"]
|
56
56
|
preset_classes = [
|
57
|
-
registered_preset_classes[x]
|
58
|
-
for x in cls._get_permissions_presets()
|
57
|
+
registered_preset_classes[x] for x in cls._get_permissions_presets()
|
59
58
|
]
|
60
59
|
if hasattr(cls, "base_permission_policy_cls"):
|
61
60
|
preset_classes.insert(0, cls.base_permission_policy_cls)
|
@@ -72,7 +71,9 @@ class PermissionsPresetsConfigMixin:
|
|
72
71
|
config_key = cls._get_presents_config_key()
|
73
72
|
if config_key in current_app.config:
|
74
73
|
return current_app.config[config_key]
|
75
|
-
return
|
74
|
+
return (
|
75
|
+
cls.PERMISSIONS_PRESETS
|
76
|
+
) # noqa (omitted here because of the order of mixins)
|
76
77
|
|
77
78
|
@classmethod
|
78
79
|
def _get_presents_config_key(cls):
|
@@ -93,5 +94,5 @@ class PermissionsPresetsConfigMixin:
|
|
93
94
|
name = cls.__name__
|
94
95
|
if name.endswith("Config"):
|
95
96
|
name = name[:-6]
|
96
|
-
name = re.sub(r
|
97
|
+
name = re.sub(r"(?<!^)(?=[A-Z])", "_", name).upper()
|
97
98
|
return f"{name}_PERMISSIONS_PRESETS"
|
@@ -24,9 +24,9 @@ class class_property:
|
|
24
24
|
self.__name__ = info.__name__
|
25
25
|
self.__module__ = info.__module__
|
26
26
|
|
27
|
-
def __get__(self, obj, type=None):
|
27
|
+
def __get__(self, obj, type=None): # NOSONAR - this is a descriptor
|
28
28
|
if obj and type is None:
|
29
|
-
type = obj.__class__
|
29
|
+
type = obj.__class__ # NOSONAR - this is a descriptor
|
30
30
|
return self.__get.__get__(obj, type)()
|
31
31
|
|
32
32
|
def __set__(self, obj, value):
|
@@ -71,6 +71,7 @@ oarepo_runtime/records/systemfields/has_draftcheck.py
|
|
71
71
|
oarepo_runtime/records/systemfields/icu.py
|
72
72
|
oarepo_runtime/records/systemfields/mapping.py
|
73
73
|
oarepo_runtime/records/systemfields/record_status.py
|
74
|
+
oarepo_runtime/records/systemfields/selectors.py
|
74
75
|
oarepo_runtime/records/systemfields/synthetic.py
|
75
76
|
oarepo_runtime/resources/__init__.py
|
76
77
|
oarepo_runtime/resources/file_resource.py
|
@@ -1,79 +0,0 @@
|
|
1
|
-
from invenio_records.systemfields import SystemField
|
2
|
-
|
3
|
-
from .mapping import MappingSystemFieldMixin
|
4
|
-
|
5
|
-
|
6
|
-
class SyntheticSystemField(MappingSystemFieldMixin, SystemField):
|
7
|
-
"""
|
8
|
-
A class that provides a synthetic system field, that is a system field that
|
9
|
-
generates its content from what is already present inside the record.
|
10
|
-
|
11
|
-
The field is not stored in the record, but is generated on the fly when
|
12
|
-
the record is being indexed.
|
13
|
-
|
14
|
-
Usage:
|
15
|
-
|
16
|
-
1. Create a new class that inherits from SyntheticSystemField
|
17
|
-
2. Implement the _value method that returns the value of the field from a data (
|
18
|
-
either a dictionary or an instance of the record class)
|
19
|
-
3. Put the class onto the record. If you use oarepo-model-builder, add it to the model
|
20
|
-
like:
|
21
|
-
```yaml
|
22
|
-
record:
|
23
|
-
record:
|
24
|
-
extra-code: |-2
|
25
|
-
# extra custom fields for facets
|
26
|
-
faculty = {{common.theses.synthetic_fields.FacultySystemField}}()
|
27
|
-
department = {{common.theses.synthetic_fields.DepartmentSystemField}}()
|
28
|
-
defenseYear = {{common.theses.synthetic_fields.DefenseYearSystemField}}()
|
29
|
-
```
|
30
|
-
|
31
|
-
4. Add the extra fields to the mapping and facets. If using oarepo-model-builder, add it to the
|
32
|
-
model like the following piece of code and compile the model:
|
33
|
-
```yaml
|
34
|
-
record:
|
35
|
-
properties:
|
36
|
-
faculty:
|
37
|
-
type: vocabulary
|
38
|
-
vocabulary-type: institutions
|
39
|
-
facets:
|
40
|
-
facet-groups:
|
41
|
-
- default
|
42
|
-
label.cs: Fakulta
|
43
|
-
label.en: Faculty
|
44
|
-
|
45
|
-
|
46
|
-
department:
|
47
|
-
type: vocabulary
|
48
|
-
vocabulary-type: institutions
|
49
|
-
facets:
|
50
|
-
facet-groups:
|
51
|
-
- default
|
52
|
-
label.cs: Ústav
|
53
|
-
label.en: Department
|
54
|
-
|
55
|
-
defenseYear:
|
56
|
-
type: integer
|
57
|
-
facets:
|
58
|
-
facet-groups:
|
59
|
-
- default
|
60
|
-
label.cs: Rok obhajoby
|
61
|
-
label.en: Defense year
|
62
|
-
```
|
63
|
-
"""
|
64
|
-
|
65
|
-
def search_dump(self, data, record):
|
66
|
-
dt = self._value(data)
|
67
|
-
if dt:
|
68
|
-
data[self.key] = dt
|
69
|
-
|
70
|
-
def search_load(self, data, record_cls):
|
71
|
-
data.pop(self.key, None)
|
72
|
-
|
73
|
-
def __get__(self, record, owner=None):
|
74
|
-
if record is None:
|
75
|
-
return self
|
76
|
-
return self._value(record)
|
77
|
-
|
78
|
-
def _value(self, data):
|
79
|
-
raise NotImplementedError("You must implement the _value method")
|
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
|
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-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/__init__.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/attachments.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/readers/service.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/semi_asynchronous.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/datastreams/writers/service.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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/dumpers/edtf_interval.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/entity_resolvers/__init__.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/entity_resolvers/proxies.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/__init__.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/internal.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/relations/pid_relation.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/featured_file.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/records/systemfields/record_status.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/custom_fields/__init__.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/custom_fields/mappings.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/expansions/__init__.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/expansions/service.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/facet_groups_names.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/facets/nested_facet.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/__init__.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/components.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/relations/mapping.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/i18n_validation.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/marshmallow.py
RENAMED
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/polymorphic.py
RENAMED
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/services/schema/validation.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/default_translations.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime/translations/jinjax_messages.jinja
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{oarepo-runtime-1.5.11 → oarepo-runtime-1.5.13}/oarepo_runtime.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|