oarepo-runtime 1.5.65__py3-none-any.whl → 1.5.66__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.
@@ -1,7 +1,10 @@
1
- from typing import Any, Callable, List
1
+ import dataclasses
2
+ from typing import Any, Callable, List, Protocol, Tuple
2
3
 
4
+ from oarepo_runtime.records.relations.lookup import lookup_key
3
5
 
4
- class Selector:
6
+
7
+ class Selector(Protocol):
5
8
  def select(self, record) -> List[Any]:
6
9
  return []
7
10
 
@@ -25,6 +28,7 @@ class FirstItemSelector(PathSelector):
25
28
  return []
26
29
 
27
30
 
31
+ @dataclasses.dataclass
28
32
  class FilteredSelector(Selector):
29
33
  """
30
34
  Selector which filters output of another selector
@@ -43,17 +47,9 @@ class FilteredSelector(Selector):
43
47
  }
44
48
  }
45
49
  """
46
-
47
- def __init__(
48
- self,
49
- selector: Selector,
50
- filter: Callable[[Any], bool],
51
- projection: Callable[[Any], Any] | str = None,
52
- ):
53
-
54
- self.selector = selector
55
- self.filter = filter
56
- self.projection = projection
50
+ selector: Selector
51
+ filter: Callable[[Any], bool]
52
+ projection: Callable[[Any], Any] | str = None
57
53
 
58
54
  def select(self, record):
59
55
  selected = self.selector.select(record)
@@ -62,10 +58,7 @@ class FilteredSelector(Selector):
62
58
  ret = []
63
59
  for select_element in selected:
64
60
  if isinstance(self.projection, str):
65
- if isinstance(select_element, dict) and self.projection in select_element:
66
- result = select_element[self.projection]
67
- else:
68
- result = []
61
+ result = [x.value for x in lookup_key(select_element, self.projection)]
69
62
  else:
70
63
  result = self.projection(select_element)
71
64
  if isinstance(result, list):
@@ -77,6 +70,7 @@ class FilteredSelector(Selector):
77
70
  return ret
78
71
 
79
72
 
73
+ @dataclasses.dataclass
80
74
  class MultiSelector(Selector):
81
75
  """Selector concatenating outputs of multiple selectors"""
82
76
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.65
3
+ Version: 1.5.66
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -64,7 +64,7 @@ oarepo_runtime/records/systemfields/icu.py,sha256=sSGAgi5WhsAY4cCBL7-7nMpvHAuctp
64
64
  oarepo_runtime/records/systemfields/mapping.py,sha256=tXOK_jkdY1pOUO7_VfChfDNB8UTi21GUXaidpugTnO8,1017
65
65
  oarepo_runtime/records/systemfields/owner.py,sha256=dYRVBinniW7ECHuSnTAjeN6x1KhhJtNR9vxmD1KswMs,3805
66
66
  oarepo_runtime/records/systemfields/record_status.py,sha256=U3kem4-JkNsT17e0iAl3HIAZ2MvO5lY_0U757aZvTKE,935
67
- oarepo_runtime/records/systemfields/selectors.py,sha256=xQEMhmqiE1M466cMilVO85V2DkELbbM3Xa8oYSCli8o,2959
67
+ oarepo_runtime/records/systemfields/selectors.py,sha256=Q9jE1smSN3heT2LIpK_jB6bIRjll1kX0AW9AhTsIYiU,2830
68
68
  oarepo_runtime/records/systemfields/synthetic.py,sha256=UustvhzcDGuaNZLDeHbWwshoxQR-qRIuHDCct5RXmrI,4287
69
69
  oarepo_runtime/resources/__init__.py,sha256=v8BGrOTu_FjKzd0eozV7Q4GoGxyfybsL2cI-tbP5Pys,185
70
70
  oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5HUHRHmidhnl8,414
@@ -121,9 +121,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
121
121
  oarepo_runtime/utils/functools.py,sha256=gKS9YZtlIYcDvdNA9cmYO00yjiXBYV1jg8VpcRUyQyg,1324
122
122
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
123
123
  tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
124
- oarepo_runtime-1.5.65.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
125
- oarepo_runtime-1.5.65.dist-info/METADATA,sha256=ZgBG9WKIQEODgFiYua5ZpiwmylRyGKmT2tIXq7mQDGo,4720
126
- oarepo_runtime-1.5.65.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
127
- oarepo_runtime-1.5.65.dist-info/entry_points.txt,sha256=0cschM0RHc6UJ1uudhu4EP0hrVStPGpgMO-XEDGRtY4,430
128
- oarepo_runtime-1.5.65.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
129
- oarepo_runtime-1.5.65.dist-info/RECORD,,
124
+ oarepo_runtime-1.5.66.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
125
+ oarepo_runtime-1.5.66.dist-info/METADATA,sha256=aWxTnz-qJ8ns7WPbokWgJEHnlw-CcUnlx1VScNmoBOE,4720
126
+ oarepo_runtime-1.5.66.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
127
+ oarepo_runtime-1.5.66.dist-info/entry_points.txt,sha256=0cschM0RHc6UJ1uudhu4EP0hrVStPGpgMO-XEDGRtY4,430
128
+ oarepo_runtime-1.5.66.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
129
+ oarepo_runtime-1.5.66.dist-info/RECORD,,