oarepo-runtime 1.2.19__tar.gz → 1.2.21__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. {oarepo-runtime-1.2.19/oarepo_runtime.egg-info → oarepo-runtime-1.2.21}/PKG-INFO +1 -1
  2. oarepo-runtime-1.2.21/oarepo_runtime/facets/base.py +9 -0
  3. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/date.py +10 -10
  4. oarepo-runtime-1.2.21/oarepo_runtime/facets/enum.py +10 -0
  5. oarepo-runtime-1.2.21/oarepo_runtime/relations/components.py +15 -0
  6. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/mapping.py +10 -0
  7. oarepo-runtime-1.2.21/oarepo_runtime/relations/uow.py +7 -0
  8. oarepo-runtime-1.2.21/oarepo_runtime/validation/__init__.py +3 -0
  9. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/validation/dates.py +16 -2
  10. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21/oarepo_runtime.egg-info}/PKG-INFO +1 -1
  11. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/SOURCES.txt +4 -0
  12. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/setup.cfg +1 -1
  13. oarepo-runtime-1.2.19/oarepo_runtime/validation/__init__.py +0 -3
  14. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/LICENSE +0 -0
  15. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/MANIFEST.in +0 -0
  16. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/README.md +0 -0
  17. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/__init__.py +0 -0
  18. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/__init__.py +0 -0
  19. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/cli.py +0 -0
  20. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cf/mappings.py +0 -0
  21. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/__init__.py +0 -0
  22. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/base.py +0 -0
  23. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/cli/index.py +0 -0
  24. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/config/__init__.py +0 -0
  25. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/config/permissions_presets.py +0 -0
  26. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/config/service.py +0 -0
  27. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/__init__.py +0 -0
  28. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/batch.py +0 -0
  29. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/catalogue.py +0 -0
  30. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/cli.py +0 -0
  31. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/config.py +0 -0
  32. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/datastreams.py +0 -0
  33. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/errors.py +0 -0
  34. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/fixtures.py +0 -0
  35. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/__init__.py +0 -0
  36. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/excel.py +0 -0
  37. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/json.py +0 -0
  38. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/service.py +0 -0
  39. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/readers/yaml.py +0 -0
  40. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/transformers.py +0 -0
  41. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/__init__.py +0 -0
  42. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/service.py +0 -0
  43. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/datastreams/writers/yaml.py +0 -0
  44. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/__init__.py +0 -0
  45. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/expandable_fields.py +0 -0
  46. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/expansions/service.py +0 -0
  47. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/ext.py +0 -0
  48. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/ext_config.py +0 -0
  49. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/__init__.py +0 -0
  50. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/max_facet.py +0 -0
  51. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/facets/nested_facet.py +0 -0
  52. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/__init__.py +0 -0
  53. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/schema.py +0 -0
  54. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/ui_schema.py +0 -0
  55. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/i18n/validation.py +0 -0
  56. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/__init__.py +0 -0
  57. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/base.py +0 -0
  58. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/internal.py +0 -0
  59. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/lookup.py +0 -0
  60. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/relations/pid_relation.py +0 -0
  61. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/tasks/__init__.py +0 -0
  62. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/tasks/datastreams.py +0 -0
  63. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/ui/__init__.py +0 -0
  64. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime/ui/marshmallow.py +0 -0
  65. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/dependency_links.txt +0 -0
  66. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/entry_points.txt +0 -0
  67. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/requires.txt +0 -0
  68. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/oarepo_runtime.egg-info/top_level.txt +0 -0
  69. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/pyproject.toml +0 -0
  70. {oarepo-runtime-1.2.19 → oarepo-runtime-1.2.21}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.2.19
3
+ Version: 1.2.21
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  Provides-Extra: devs
@@ -0,0 +1,9 @@
1
+ from invenio_records_resources.services.records.facets import TermsFacet
2
+
3
+
4
+ class LabelledValuesTermsFacet(TermsFacet):
5
+ def __init__(self, *args, **kwargs):
6
+ super().__init__(*args, **{"value_labels": self.value_labels, **kwargs})
7
+
8
+ def value_labels(self, values):
9
+ return {val: val for val in values}
@@ -1,4 +1,3 @@
1
- from invenio_records_resources.services.records.facets import TermsFacet
2
1
  from oarepo_runtime.ui.marshmallow import (
3
2
  LocalizedDate,
4
3
  LocalizedTime,
@@ -7,14 +6,9 @@ from oarepo_runtime.ui.marshmallow import (
7
6
  LocalizedEDTFInterval,
8
7
  )
9
8
  import re
10
-
11
-
12
- class LabelledValuesTermsFacet(TermsFacet):
13
- def __init__(self, *args, **kwargs):
14
- super().__init__(*args, **{"value_labels": self.value_labels, **kwargs})
15
-
16
- def value_labels(self, values):
17
- return {val: val for val in values}
9
+ from .base import LabelledValuesTermsFacet
10
+ from invenio_search.engine import dsl
11
+ from invenio_records_resources.services.records.facets.facets import LabelledFacetMixin
18
12
 
19
13
 
20
14
  class DateFacet(LabelledValuesTermsFacet):
@@ -39,7 +33,13 @@ class EDTFFacet(LabelledValuesTermsFacet):
39
33
  }
40
34
 
41
35
 
42
- class EDTFIntervalFacet(LabelledValuesTermsFacet):
36
+ class EDTFIntervalFacet(LabelledFacetMixin, dsl.DateHistogramFacet):
37
+ # auto_date_histogram
38
+ def __init__(self, *args, **kwargs):
39
+ if "interval" not in kwargs:
40
+ kwargs["interval"] = "year"
41
+ super().__init__(*args, **kwargs)
42
+
43
43
  def value_labels(self, values):
44
44
  return {
45
45
  val: LocalizedEDTFInterval().format_value(convert_to_edtf(val))
@@ -0,0 +1,10 @@
1
+ from .base import LabelledValuesTermsFacet
2
+ from flask_babelex import lazy_gettext
3
+
4
+
5
+ class EnumTermsFacet(LabelledValuesTermsFacet):
6
+ def value_labels(self, values):
7
+ field = self._params["field"]
8
+ field_path = field.replace(".", "/")
9
+ field_enum = f"{field_path}.enum."
10
+ return {val: lazy_gettext(f"{field_enum}{val}") for val in values}
@@ -0,0 +1,15 @@
1
+ from invenio_records_resources.services.records.components import ServiceComponent
2
+
3
+ from oarepo_runtime.relations import PIDRelation
4
+ from oarepo_runtime.relations.uow import CachingUnitOfWork
5
+
6
+
7
+ class CachingRelationsComponent(ServiceComponent):
8
+ def create(self, identity, *, record, **kwargs):
9
+ """Create handler."""
10
+ # skutecny jmeno relations atributu
11
+ if isinstance(self.uow, CachingUnitOfWork) and hasattr(record, "relations"):
12
+ record.relations.set_cache(self.uow.cache)
13
+ def update(self, identity, *, record, **kwargs):
14
+ """Update handler."""
15
+ self.create(identity, record=record, **kwargs)
@@ -1,3 +1,6 @@
1
+
2
+
3
+
1
4
  class RelationsMapping:
2
5
  """Helper class for managing relation fields."""
3
6
 
@@ -28,3 +31,10 @@ class RelationsMapping:
28
31
  """Clean dereferenced relation fields."""
29
32
  for name in fields or self:
30
33
  getattr(self, name).clean()
34
+
35
+ def set_cache(self, cache):
36
+ from oarepo_runtime.relations import PIDRelation
37
+ for key, fld in self._fields.items():
38
+ if isinstance(fld, PIDRelation):
39
+ fld.cache = cache
40
+ getattr(self, key).cache = cache
@@ -0,0 +1,7 @@
1
+ from invenio_records_resources.services.uow import UnitOfWork
2
+
3
+
4
+ class CachingUnitOfWork(UnitOfWork):
5
+ def __init__(self, *args, **kwargs):
6
+ super().__init__(*args, **kwargs)
7
+ self.cache = {}
@@ -0,0 +1,3 @@
1
+ from .dates import validate_date, validate_datetime, CachedMultilayerEDTFValidator
2
+
3
+ __all__ = ["validate_date", "validate_datetime", "CachedMultilayerEDTFValidator"]
@@ -1,6 +1,8 @@
1
+ import functools
2
+ import re
1
3
  from datetime import datetime
2
-
3
4
  from marshmallow.exceptions import ValidationError
5
+ from marshmallow_utils.fields.edtfdatestring import EDTFValidator
4
6
 
5
7
 
6
8
  def validate_date(date_format):
@@ -14,7 +16,6 @@ def validate_date(date_format):
14
16
 
15
17
  return validate
16
18
 
17
-
18
19
  def validate_datetime(value):
19
20
  try:
20
21
  datetime.fromisoformat(value)
@@ -22,3 +23,16 @@ def validate_datetime(value):
22
23
  raise ValidationError(
23
24
  f"Invalid datetime format, expecting iso format, got {value}"
24
25
  ) from e
26
+
27
+ class CachedMultilayerEDTFValidator(EDTFValidator):
28
+
29
+ @functools.lru_cache(maxsize=1024)
30
+ def __call__(self, value):
31
+ if re.match(r"^\d{4}$", value):
32
+ return value
33
+ try:
34
+ datetime.strptime(value, "%Y-%m-%d")
35
+ return value
36
+ except:
37
+ return super().__call__(value)
38
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.2.19
3
+ Version: 1.2.21
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  Provides-Extra: devs
@@ -43,7 +43,9 @@ oarepo_runtime/expansions/__init__.py
43
43
  oarepo_runtime/expansions/expandable_fields.py
44
44
  oarepo_runtime/expansions/service.py
45
45
  oarepo_runtime/facets/__init__.py
46
+ oarepo_runtime/facets/base.py
46
47
  oarepo_runtime/facets/date.py
48
+ oarepo_runtime/facets/enum.py
47
49
  oarepo_runtime/facets/max_facet.py
48
50
  oarepo_runtime/facets/nested_facet.py
49
51
  oarepo_runtime/i18n/__init__.py
@@ -52,10 +54,12 @@ oarepo_runtime/i18n/ui_schema.py
52
54
  oarepo_runtime/i18n/validation.py
53
55
  oarepo_runtime/relations/__init__.py
54
56
  oarepo_runtime/relations/base.py
57
+ oarepo_runtime/relations/components.py
55
58
  oarepo_runtime/relations/internal.py
56
59
  oarepo_runtime/relations/lookup.py
57
60
  oarepo_runtime/relations/mapping.py
58
61
  oarepo_runtime/relations/pid_relation.py
62
+ oarepo_runtime/relations/uow.py
59
63
  oarepo_runtime/tasks/__init__.py
60
64
  oarepo_runtime/tasks/datastreams.py
61
65
  oarepo_runtime/ui/__init__.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = oarepo-runtime
3
- version = 1.2.19
3
+ version = 1.2.21
4
4
  description = A set of runtime extensions of Invenio repository
5
5
  authors = Alzbeta
6
6
  readme = README.md
@@ -1,3 +0,0 @@
1
- from .dates import validate_date, validate_datetime
2
-
3
- __all__ = ["validate_date", "validate_datetime"]
File without changes