oarepo-runtime 2.0.0.dev34__py3-none-any.whl → 2.0.0.dev36__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.
@@ -19,6 +19,6 @@ from .api import Model
19
19
  from .ext import OARepoRuntime
20
20
  from .proxies import current_runtime
21
21
 
22
- __version__ = "2.0.0dev34"
22
+ __version__ = "2.0.0dev36"
23
23
 
24
24
  __all__ = ("Model", "OARepoRuntime", "__version__", "current_runtime")
@@ -10,20 +10,15 @@
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
- from typing import TYPE_CHECKING, Any, override
13
+ from typing import TYPE_CHECKING
14
14
 
15
15
  from invenio_records.api import Record
16
16
 
17
- from .base import TypedSystemField
18
-
19
17
  if TYPE_CHECKING:
20
18
  from invenio_records.dumpers import Dumper
21
- from invenio_records.systemfields import SystemField
22
- else:
23
- SystemField = object
24
19
 
25
20
 
26
- class MappingSystemFieldMixin[R: Record = Record, V: Any = Any](TypedSystemField[R, V]):
21
+ class MappingSystemFieldMixin[R: Record = Record]:
27
22
  """Mixin class that provides default mapping, mapping settings, and dynamic templates for system fields."""
28
23
 
29
24
  @property
@@ -42,18 +37,14 @@ class MappingSystemFieldMixin[R: Record = Record, V: Any = Any](TypedSystemField
42
37
  return []
43
38
 
44
39
  # The following methods are added just for typing purposes.
45
- @override
46
40
  def pre_dump(self, record: R, data: dict, dumper: Dumper | None = None) -> None:
47
41
  """Dump record to the data - pre-dump phase."""
48
42
 
49
- @override
50
43
  def post_dump(self, record: R, data: dict, dumper: Dumper | None = None) -> None:
51
44
  """Dump record to the data - post-dump phase."""
52
45
 
53
- @override
54
46
  def pre_load(self, data: dict, loader: Dumper | None = None) -> None:
55
47
  """Load record from the data - pre-load phase."""
56
48
 
57
- @override
58
49
  def post_load(self, record: R, data: dict, loader: Dumper | None = None) -> None:
59
50
  """Load record from the data - post-load phase."""
@@ -10,17 +10,18 @@
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
- from typing import TYPE_CHECKING, Any, override
13
+ from typing import TYPE_CHECKING, Self, override
14
14
 
15
15
  from invenio_records.api import Record
16
16
 
17
+ from .base import TypedSystemField
17
18
  from .mapping import MappingSystemFieldMixin
18
19
 
19
20
  if TYPE_CHECKING:
20
21
  from invenio_records.dumpers import Dumper
21
22
 
22
23
 
23
- class PublicationStatusSystemField(MappingSystemFieldMixin[Record, str]):
24
+ class PublicationStatusSystemField(MappingSystemFieldMixin, TypedSystemField[Record, str]):
24
25
  """A system field to track the status of a record (either 'draft' or 'published').
25
26
 
26
27
  The default key for this field is 'publication_status', but it can be customized.
@@ -45,16 +46,15 @@ class PublicationStatusSystemField(MappingSystemFieldMixin[Record, str]):
45
46
 
46
47
  @override
47
48
  def post_dump(self, record: Record, data: dict, dumper: Dumper | None = None) -> None:
48
- if self.key is None:
49
- return # pragma: no cover
50
49
  if not self.attr_name:
51
50
  raise ValueError( # pragma: no cover
52
51
  "attr_name must be set for PublicationStatusSystemField"
53
52
  )
54
53
  data[self.key] = getattr(record, self.attr_name)
55
54
 
56
- def __get__(self, record: Record | None, owner: Any = None) -> Any:
55
+ @override
56
+ def __get__(self, instance: Record | None, owner: type[Record]) -> Self | str: # type: ignore[override]
57
57
  """Access the attribute."""
58
- if record is None:
58
+ if instance is None:
59
59
  return self
60
- return "draft" if getattr(record, "is_draft", False) else "published"
60
+ return "draft" if getattr(instance, "is_draft", False) else "published"
oarepo_runtime/typing.py CHANGED
@@ -16,6 +16,9 @@ from typing import TYPE_CHECKING, Any
16
16
  if TYPE_CHECKING:
17
17
  from collections.abc import Callable
18
18
 
19
+ from invenio_records_resources.records.api import Record
20
+ from invenio_records_resources.services.records.results import RecordItem
21
+
19
22
 
20
23
  def require_kwargs(*kwargs_names: str) -> Any:
21
24
  """Wrap function to require specific kwargs in a function call.
@@ -58,3 +61,8 @@ def require_kwargs(*kwargs_names: str) -> Any:
58
61
  return wrapped_f
59
62
 
60
63
  return wrapper
64
+
65
+
66
+ def record_from_result(result: RecordItem) -> Record:
67
+ """Convert a RecordItem to a Record."""
68
+ return result._record # noqa: SLF001
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oarepo-runtime
3
- Version: 2.0.0.dev34
3
+ Version: 2.0.0.dev36
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Project-URL: Homepage, https://github.com/oarepo/oarepo-runtime
6
6
  License-Expression: MIT
@@ -1,10 +1,10 @@
1
- oarepo_runtime/__init__.py,sha256=1s8_0r4mP7KwNdjxpvOFL2O-NObepsa8Ye1USLhrnVc,686
1
+ oarepo_runtime/__init__.py,sha256=Y5ZPbHF2q3Fi0ElItUf0wzaM3aP_xOw-MkJntFLkO8E,686
2
2
  oarepo_runtime/api.py,sha256=6AHyFnf0Cg1nfhGaQFMPjynVvrp1UURo8vX5vb5LvC4,14169
3
3
  oarepo_runtime/config.py,sha256=RUEPFn_5bKp9Wb0OY-Fb3VK30m35vF5IsLjYaQHhP3g,3838
4
4
  oarepo_runtime/ext.py,sha256=NgiRNl_hwTvEWcXnNwVh_XCPJyvwr3dZkdPmkWvN1xo,8785
5
5
  oarepo_runtime/proxies.py,sha256=x8Y1iTP8QIzSI67s90VR0_5fvXuT1xlJXtAHsaoXFwg,903
6
6
  oarepo_runtime/py.typed,sha256=RznSCjXReEUI9zkmD25E8XniG_MvPpLBF6MyNZA8MmE,42
7
- oarepo_runtime/typing.py,sha256=vH8UUb4QTJowuvibwHaOOEwxx8i21LcOeplxJl0Yrew,1594
7
+ oarepo_runtime/typing.py,sha256=VtINHm4BZ5OJ4KdRAwnFXPZiAEgPRIYTtPC9fIzK1bU,1876
8
8
  oarepo_runtime/cli/__init__.py,sha256=H7GOeOBf0udgKWOdlAQswIMvRrD8BwcEjOVxIqP0Suw,731
9
9
  oarepo_runtime/cli/search.py,sha256=4fHkrjltUUPVUzJiuWaiWxTk62rIYxal3_3jRsZVMmI,1175
10
10
  oarepo_runtime/info/__init__.py,sha256=qRG3mSyoiw7sKm9StiuBJs6l15HrdAQ4sphsAQsJtQc,336
@@ -16,8 +16,8 @@ oarepo_runtime/records/pid_providers.py,sha256=DE8uW-QmJumA9OqWksDOydezjJ9LLC296
16
16
  oarepo_runtime/records/systemfields/__init__.py,sha256=tJzOOQ8dBlCyD8tCAriIUZggZ73UjMyMOp6IlSV-Tb4,594
17
17
  oarepo_runtime/records/systemfields/base.py,sha256=EWSdVsWePkdwksRQ9yaMMk9Mrhicw-ZE0vdApn2EjWQ,1602
18
18
  oarepo_runtime/records/systemfields/custom_fields.py,sha256=PEoaCEnvanysFQAaqTtD9-VwaBmnFkoP2pmpCl9ZFfI,2237
19
- oarepo_runtime/records/systemfields/mapping.py,sha256=FPvGZH-pTJejr2qiYerXSrNpIti5r66gDas5nBK-ib4,1932
20
- oarepo_runtime/records/systemfields/publication_status.py,sha256=Q2Pa1wJiNiEWrAEDVwVU9IjFPo1agBXQ-1uCcNDZStg,1954
19
+ oarepo_runtime/records/systemfields/mapping.py,sha256=GcNp_-Ho3G8nk4-SXgoWWk_IPdGsM0LZ-DBl5fnYJvE,1699
20
+ oarepo_runtime/records/systemfields/publication_status.py,sha256=5D8L_-Wsf-Or-Er7EhuOnwzXfGY28TRPTg1XmMEKxM8,1995
21
21
  oarepo_runtime/records/systemfields/selectors.py,sha256=ijVDwAXaXTV5NtcXsrALkhddgCogLNe2eEscFr23qyg,1656
22
22
  oarepo_runtime/resources/__init__.py,sha256=voynQULXoOEviADkbOpekMphZPTAz4IOTg5BF9xPwTM,453
23
23
  oarepo_runtime/resources/config.py,sha256=Lbx1QPWAJ8z1truhYntbnhGGWp2OCcwqKm6BuvPJNT0,1330
@@ -42,8 +42,8 @@ oarepo_runtime/services/schema/__init__.py,sha256=jgAPI_uKC6Ug4KQWnwQVg3-aNaw-eH
42
42
  oarepo_runtime/services/schema/i18n.py,sha256=9D1zOQaPKAnYzejB0vO-m2BJYnam0N0Lrq4jID7twfE,3174
43
43
  oarepo_runtime/services/schema/i18n_ui.py,sha256=DbusphhGDeaobTt4nuwNgKZ6Houlu4Sv3SuMGkdjRRY,3582
44
44
  oarepo_runtime/services/schema/ui.py,sha256=Y_jBO-fowkpOgceWz8aqJSJAUiAnKLGSIuNpjNLnp8Q,4612
45
- oarepo_runtime-2.0.0.dev34.dist-info/METADATA,sha256=w1wReJPYVkTR6iFXH1dzdcbExSD4ImSbPkQg2wjdpHc,4707
46
- oarepo_runtime-2.0.0.dev34.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- oarepo_runtime-2.0.0.dev34.dist-info/entry_points.txt,sha256=rOfs8R1oXFN_dLH9zAZ6ydkvr83mDajegc6NBIRsCMQ,318
48
- oarepo_runtime-2.0.0.dev34.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
49
- oarepo_runtime-2.0.0.dev34.dist-info/RECORD,,
45
+ oarepo_runtime-2.0.0.dev36.dist-info/METADATA,sha256=4wSsN4WdUaamDR4j3jrH-uj9K8b_NYhhpE_BA6TTh90,4707
46
+ oarepo_runtime-2.0.0.dev36.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ oarepo_runtime-2.0.0.dev36.dist-info/entry_points.txt,sha256=rOfs8R1oXFN_dLH9zAZ6ydkvr83mDajegc6NBIRsCMQ,318
48
+ oarepo_runtime-2.0.0.dev36.dist-info/licenses/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
49
+ oarepo_runtime-2.0.0.dev36.dist-info/RECORD,,