elody 0.0.191__py3-none-any.whl → 0.0.193__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.
- elody/object_configurations/base_object_configuration.py +10 -0
- elody/object_configurations/elody_configuration.py +47 -21
- {elody-0.0.191.dist-info → elody-0.0.193.dist-info}/METADATA +1 -1
- {elody-0.0.191.dist-info → elody-0.0.193.dist-info}/RECORD +7 -7
- {elody-0.0.191.dist-info → elody-0.0.193.dist-info}/WHEEL +1 -1
- {elody-0.0.191.dist-info → elody-0.0.193.dist-info}/licenses/LICENSE +0 -0
- {elody-0.0.191.dist-info → elody-0.0.193.dist-info}/top_level.txt +0 -0
|
@@ -103,6 +103,16 @@ class BaseObjectConfiguration(ABC):
|
|
|
103
103
|
)
|
|
104
104
|
if sanitized_value:
|
|
105
105
|
sanitized_document[key] = sanitized_value
|
|
106
|
+
elif isinstance(value, list):
|
|
107
|
+
sanitized_document[key] = [
|
|
108
|
+
element.strip() if isinstance(element, str) else element
|
|
109
|
+
for element in value
|
|
110
|
+
if element
|
|
111
|
+
]
|
|
112
|
+
elif isinstance(value, str):
|
|
113
|
+
lines = value.splitlines()
|
|
114
|
+
value = "\n".join(line.strip() for line in lines).strip()
|
|
115
|
+
sanitized_document[key] = value.strip()
|
|
106
116
|
elif value:
|
|
107
117
|
sanitized_document[key] = value
|
|
108
118
|
return sanitized_document
|
|
@@ -45,11 +45,12 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
45
45
|
flat_post_body={},
|
|
46
46
|
document_defaults={},
|
|
47
47
|
):
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
flat_post_body = flat_post_body or flatten_dict(
|
|
49
|
+
self.document_info()["object_lists"],
|
|
50
|
+
post_body if isinstance(post_body, dict) else {},
|
|
51
|
+
)
|
|
52
52
|
_id = document_defaults.get("_id", str(uuid4()))
|
|
53
|
+
timestamp = datetime.now(timezone.utc)
|
|
53
54
|
|
|
54
55
|
identifiers = []
|
|
55
56
|
for property in self.document_info().get("identifier_properties", []):
|
|
@@ -66,15 +67,20 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
66
67
|
"schema": {"type": self.SCHEMA_TYPE, "version": self.SCHEMA_VERSION},
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
if isinstance(post_body, dict):
|
|
71
|
+
for key, object_list_key in self.document_info()["object_lists"].items():
|
|
72
|
+
if not key.startswith("lookup.virtual_relations"):
|
|
73
|
+
post_body[key] = self._merge_object_lists(
|
|
74
|
+
document_defaults.get(key, []),
|
|
75
|
+
post_body.get(key, []),
|
|
76
|
+
object_list_key,
|
|
77
|
+
)
|
|
78
|
+
document = {**template, **document_defaults, **post_body}
|
|
79
|
+
else:
|
|
80
|
+
document = {**template, **document_defaults}
|
|
81
|
+
document = self._pre_crud_hook(
|
|
82
|
+
crud="create", timestamp=timestamp, document=document
|
|
83
|
+
)
|
|
78
84
|
return document
|
|
79
85
|
|
|
80
86
|
def _document_content_patcher(self, *, document, content, overwrite=False, **_):
|
|
@@ -104,33 +110,53 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
104
110
|
def _post_crud_hook(self, **kwargs):
|
|
105
111
|
pass
|
|
106
112
|
|
|
107
|
-
def _pre_crud_hook(self, *, crud, document={}, **kwargs):
|
|
113
|
+
def _pre_crud_hook(self, *, crud, timestamp, document={}, **kwargs):
|
|
108
114
|
if document:
|
|
115
|
+
document = self.__patch_document_unique_value(document)
|
|
116
|
+
document = self.__patch_document_audit_info(crud, document, timestamp)
|
|
109
117
|
document = self._sanitize_document(
|
|
110
118
|
document=document,
|
|
111
119
|
object_list_name="metadata",
|
|
112
120
|
object_list_value_field_name="value",
|
|
113
121
|
)
|
|
114
|
-
document = self.
|
|
122
|
+
document = self._sanitize_document(
|
|
123
|
+
document=document,
|
|
124
|
+
object_list_name="relations",
|
|
125
|
+
object_list_value_field_name="key",
|
|
126
|
+
)
|
|
115
127
|
document = self._sort_document_keys(document)
|
|
116
128
|
return document
|
|
117
129
|
|
|
118
130
|
def _sanitize_document(
|
|
119
131
|
self, *, document, object_list_name, object_list_value_field_name, **kwargs
|
|
120
132
|
):
|
|
121
|
-
sanitized_document = super()._sanitize_document(document=document)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if not element[object_list_value_field_name]:
|
|
133
|
+
sanitized_document = super()._sanitize_document(document=document, **kwargs)
|
|
134
|
+
for element in document[object_list_name]:
|
|
135
|
+
if not element.get(object_list_value_field_name):
|
|
125
136
|
sanitized_document[object_list_name].remove(element)
|
|
137
|
+
for element in sanitized_document[object_list_name]:
|
|
138
|
+
value = element[object_list_value_field_name]
|
|
139
|
+
if isinstance(value, str):
|
|
140
|
+
lines = value.splitlines()
|
|
141
|
+
value = "\n".join(line.strip() for line in lines).strip()
|
|
142
|
+
element[object_list_value_field_name] = value.strip()
|
|
126
143
|
return sanitized_document
|
|
127
144
|
|
|
128
|
-
def
|
|
129
|
-
document.update({f"date_{crud}d":
|
|
145
|
+
def __patch_document_audit_info(self, crud, document, timestamp):
|
|
146
|
+
document.update({f"date_{crud}d": timestamp})
|
|
130
147
|
if email := self._get_user_context_id():
|
|
131
148
|
document.update({"last_editor": email})
|
|
132
149
|
return document
|
|
133
150
|
|
|
151
|
+
def __patch_document_unique_value(self, document):
|
|
152
|
+
if unique_field := self.document_info().get("unique_field"):
|
|
153
|
+
flat_document = flatten_dict(
|
|
154
|
+
self.document_info().get("object_lists", {}), document
|
|
155
|
+
)
|
|
156
|
+
if value := flat_document.get(unique_field):
|
|
157
|
+
document["unique_field"] = f"{document['type']}:{value}"
|
|
158
|
+
return document
|
|
159
|
+
|
|
134
160
|
def _sorting(self, key_order_map, **_):
|
|
135
161
|
addFields, sort = {}, {}
|
|
136
162
|
for key, order in key_order_map.items():
|
|
@@ -12,8 +12,8 @@ elody/validator.py,sha256=G7Ya538EJHCFzOxEri2OcFMabfLBCtTKxuf4os_KuNw,260
|
|
|
12
12
|
elody/migration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
elody/migration/base_object_migrator.py,sha256=n8uvgGfjEUy60G47RD7Y-oxp1vHLOauwPMDl87LcxtU,436
|
|
14
14
|
elody/object_configurations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
elody/object_configurations/base_object_configuration.py,sha256=
|
|
16
|
-
elody/object_configurations/elody_configuration.py,sha256=
|
|
15
|
+
elody/object_configurations/base_object_configuration.py,sha256=Jn39KS-GesMIf-rVd5S-Zpjezv1YUo7KUkuScecudd8,7223
|
|
16
|
+
elody/object_configurations/elody_configuration.py,sha256=H3iqNXPhYX6scR7C57L_hCWQH2MnWKwnH3vegLg-UGw,7645
|
|
17
17
|
elody/object_configurations/job_configuration.py,sha256=HMDxaRUyfqhIy0q3yQDDMH9uW5iCd7VCmqknQofXNt0,2039
|
|
18
18
|
elody/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
elody/policies/helpers.py,sha256=AV3wtvthJafW6ueEYGxggB5kk5knWTWzh3zq29Y1-ws,1434
|
|
@@ -35,13 +35,13 @@ elody/policies/authorization/mediafile_derivatives_policy.py,sha256=0JHg0gsj7pdH
|
|
|
35
35
|
elody/policies/authorization/mediafile_download_policy.py,sha256=I9j-w_CrfC1vJ9AqJetKQW9ebs0zur-Wfshrb_cN8vU,2535
|
|
36
36
|
elody/policies/authorization/multi_tenant_policy.py,sha256=SA9H7SBjzuh8mY3gYN7pDG8TV7hdI3GEUtNeiZeNL3M,3164
|
|
37
37
|
elody/policies/authorization/tenant_request_policy.py,sha256=dEgblwRAqwWVcE-O7Jn8hVL3OnwDlQhDEOcPlcElBrk,1185
|
|
38
|
-
elody-0.0.
|
|
38
|
+
elody-0.0.193.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
39
39
|
tests/__init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
40
|
tests/data.py,sha256=Q3oxduf-E3m-Z5G_p3fcs8jVy6g10I7zXKL1m94UVMI,2906
|
|
41
41
|
tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
42
|
tests/unit/test_csv.py,sha256=NQaOhehfQ4GuXku0Y1SA8DYjJeqqidbF50zEHAi8RZA,15923
|
|
43
43
|
tests/unit/test_utils.py,sha256=g63szcEZyHhCOtrW4BnNbcgVca3oYPIOLjBdIzNwwN0,8784
|
|
44
|
-
elody-0.0.
|
|
45
|
-
elody-0.0.
|
|
46
|
-
elody-0.0.
|
|
47
|
-
elody-0.0.
|
|
44
|
+
elody-0.0.193.dist-info/METADATA,sha256=dDSZz4Mfpv3ciUEJWpSUeZ0EGplX7D10MoywzaIdN6w,23358
|
|
45
|
+
elody-0.0.193.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
46
|
+
elody-0.0.193.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
|
|
47
|
+
elody-0.0.193.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|