elody 0.0.192__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 +9 -1
- elody/object_configurations/elody_configuration.py +32 -9
- {elody-0.0.192.dist-info → elody-0.0.193.dist-info}/METADATA +1 -1
- {elody-0.0.192.dist-info → elody-0.0.193.dist-info}/RECORD +7 -7
- {elody-0.0.192.dist-info → elody-0.0.193.dist-info}/WHEEL +1 -1
- {elody-0.0.192.dist-info → elody-0.0.193.dist-info}/licenses/LICENSE +0 -0
- {elody-0.0.192.dist-info → elody-0.0.193.dist-info}/top_level.txt +0 -0
|
@@ -104,7 +104,15 @@ class BaseObjectConfiguration(ABC):
|
|
|
104
104
|
if sanitized_value:
|
|
105
105
|
sanitized_document[key] = sanitized_value
|
|
106
106
|
elif isinstance(value, list):
|
|
107
|
-
sanitized_document[key] = [
|
|
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()
|
|
108
116
|
elif value:
|
|
109
117
|
sanitized_document[key] = value
|
|
110
118
|
return sanitized_document
|
|
@@ -50,6 +50,7 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
50
50
|
post_body if isinstance(post_body, dict) else {},
|
|
51
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", []):
|
|
@@ -77,7 +78,9 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
77
78
|
document = {**template, **document_defaults, **post_body}
|
|
78
79
|
else:
|
|
79
80
|
document = {**template, **document_defaults}
|
|
80
|
-
document = self._pre_crud_hook(
|
|
81
|
+
document = self._pre_crud_hook(
|
|
82
|
+
crud="create", timestamp=timestamp, document=document
|
|
83
|
+
)
|
|
81
84
|
return document
|
|
82
85
|
|
|
83
86
|
def _document_content_patcher(self, *, document, content, overwrite=False, **_):
|
|
@@ -107,33 +110,53 @@ class ElodyConfiguration(BaseObjectConfiguration):
|
|
|
107
110
|
def _post_crud_hook(self, **kwargs):
|
|
108
111
|
pass
|
|
109
112
|
|
|
110
|
-
def _pre_crud_hook(self, *, crud, document={}, **kwargs):
|
|
113
|
+
def _pre_crud_hook(self, *, crud, timestamp, document={}, **kwargs):
|
|
111
114
|
if document:
|
|
115
|
+
document = self.__patch_document_unique_value(document)
|
|
116
|
+
document = self.__patch_document_audit_info(crud, document, timestamp)
|
|
112
117
|
document = self._sanitize_document(
|
|
113
118
|
document=document,
|
|
114
119
|
object_list_name="metadata",
|
|
115
120
|
object_list_value_field_name="value",
|
|
116
121
|
)
|
|
117
|
-
document = self.
|
|
122
|
+
document = self._sanitize_document(
|
|
123
|
+
document=document,
|
|
124
|
+
object_list_name="relations",
|
|
125
|
+
object_list_value_field_name="key",
|
|
126
|
+
)
|
|
118
127
|
document = self._sort_document_keys(document)
|
|
119
128
|
return document
|
|
120
129
|
|
|
121
130
|
def _sanitize_document(
|
|
122
131
|
self, *, document, object_list_name, object_list_value_field_name, **kwargs
|
|
123
132
|
):
|
|
124
|
-
sanitized_document = super()._sanitize_document(document=document)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
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):
|
|
128
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()
|
|
129
143
|
return sanitized_document
|
|
130
144
|
|
|
131
|
-
def
|
|
132
|
-
document.update({f"date_{crud}d":
|
|
145
|
+
def __patch_document_audit_info(self, crud, document, timestamp):
|
|
146
|
+
document.update({f"date_{crud}d": timestamp})
|
|
133
147
|
if email := self._get_user_context_id():
|
|
134
148
|
document.update({"last_editor": email})
|
|
135
149
|
return document
|
|
136
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
|
+
|
|
137
160
|
def _sorting(self, key_order_map, **_):
|
|
138
161
|
addFields, sort = {}, {}
|
|
139
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
|