elody 0.0.192__tar.gz → 0.0.194__tar.gz

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.
Files changed (52) hide show
  1. {elody-0.0.192 → elody-0.0.194}/PKG-INFO +1 -1
  2. {elody-0.0.192 → elody-0.0.194}/pyproject.toml +1 -1
  3. {elody-0.0.192 → elody-0.0.194}/src/elody/object_configurations/base_object_configuration.py +11 -1
  4. {elody-0.0.192 → elody-0.0.194}/src/elody/object_configurations/elody_configuration.py +32 -9
  5. {elody-0.0.192 → elody-0.0.194}/src/elody.egg-info/PKG-INFO +1 -1
  6. {elody-0.0.192 → elody-0.0.194}/LICENSE +0 -0
  7. {elody-0.0.192 → elody-0.0.194}/README.md +0 -0
  8. {elody-0.0.192 → elody-0.0.194}/setup.cfg +0 -0
  9. {elody-0.0.192 → elody-0.0.194}/src/__init__.py +0 -0
  10. {elody-0.0.192 → elody-0.0.194}/src/elody/__init__.py +0 -0
  11. {elody-0.0.192 → elody-0.0.194}/src/elody/client.py +0 -0
  12. {elody-0.0.192 → elody-0.0.194}/src/elody/csv.py +0 -0
  13. {elody-0.0.192 → elody-0.0.194}/src/elody/error_codes.py +0 -0
  14. {elody-0.0.192 → elody-0.0.194}/src/elody/exceptions.py +0 -0
  15. {elody-0.0.192 → elody-0.0.194}/src/elody/job.py +0 -0
  16. {elody-0.0.192 → elody-0.0.194}/src/elody/loader.py +0 -0
  17. {elody-0.0.192 → elody-0.0.194}/src/elody/migration/__init__.py +0 -0
  18. {elody-0.0.192 → elody-0.0.194}/src/elody/migration/base_object_migrator.py +0 -0
  19. {elody-0.0.192 → elody-0.0.194}/src/elody/object_configurations/__init__.py +0 -0
  20. {elody-0.0.192 → elody-0.0.194}/src/elody/object_configurations/job_configuration.py +0 -0
  21. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/__init__.py +0 -0
  22. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authentication/__init__.py +0 -0
  23. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authentication/base_user_tenant_validation_policy.py +0 -0
  24. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authentication/multi_tenant_policy.py +0 -0
  25. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/__init__.py +0 -0
  26. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/filter_generic_objects_policy.py +0 -0
  27. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/filter_generic_objects_policy_v2.py +0 -0
  28. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_detail_policy.py +0 -0
  29. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_mediafiles_policy.py +0 -0
  30. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_metadata_policy.py +0 -0
  31. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_relations_policy.py +0 -0
  32. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_request_policy.py +0 -0
  33. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/generic_object_request_policy_v2.py +0 -0
  34. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/mediafile_derivatives_policy.py +0 -0
  35. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/mediafile_download_policy.py +0 -0
  36. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/multi_tenant_policy.py +0 -0
  37. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/authorization/tenant_request_policy.py +0 -0
  38. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/helpers.py +0 -0
  39. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/permission_handler.py +0 -0
  40. {elody-0.0.192 → elody-0.0.194}/src/elody/policies/tenant_id_resolver.py +0 -0
  41. {elody-0.0.192 → elody-0.0.194}/src/elody/schemas.py +0 -0
  42. {elody-0.0.192 → elody-0.0.194}/src/elody/util.py +0 -0
  43. {elody-0.0.192 → elody-0.0.194}/src/elody/validator.py +0 -0
  44. {elody-0.0.192 → elody-0.0.194}/src/elody.egg-info/SOURCES.txt +0 -0
  45. {elody-0.0.192 → elody-0.0.194}/src/elody.egg-info/dependency_links.txt +0 -0
  46. {elody-0.0.192 → elody-0.0.194}/src/elody.egg-info/requires.txt +0 -0
  47. {elody-0.0.192 → elody-0.0.194}/src/elody.egg-info/top_level.txt +0 -0
  48. {elody-0.0.192 → elody-0.0.194}/src/tests/__init_.py +0 -0
  49. {elody-0.0.192 → elody-0.0.194}/src/tests/data.py +0 -0
  50. {elody-0.0.192 → elody-0.0.194}/src/tests/unit/__init__.py +0 -0
  51. {elody-0.0.192 → elody-0.0.194}/src/tests/unit/test_csv.py +0 -0
  52. {elody-0.0.192 → elody-0.0.194}/src/tests/unit/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: elody
3
- Version: 0.0.192
3
+ Version: 0.0.194
4
4
  Summary: elody SDK for Python
5
5
  Author-email: Inuits <developers@inuits.eu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "elody"
9
- version = "0.0.192"
9
+ version = "0.0.194"
10
10
  description = "elody SDK for Python"
11
11
  readme = "README.md"
12
12
  authors = [{ name = "Inuits", email = "developers@inuits.eu" }]
@@ -104,7 +104,17 @@ 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] = [element for element in value if element]
107
+ sanitized_document[key] = [
108
+ element.strip() if isinstance(element, str) else element
109
+ for element in value
110
+ if element
111
+ ]
112
+ if all(isinstance(element, str) for element in sanitized_document[key]):
113
+ sanitized_document[key] = list(set(sanitized_document[key]))
114
+ elif isinstance(value, str):
115
+ lines = value.splitlines()
116
+ value = "\n".join(line.strip() for line in lines).strip()
117
+ sanitized_document[key] = value.strip()
108
118
  elif value:
109
119
  sanitized_document[key] = value
110
120
  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(crud="create", document=document)
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.__patch_document(crud, document)
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
- object_list = document[object_list_name]
126
- for element in object_list:
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 __patch_document(self, crud, document):
132
- document.update({f"date_{crud}d": datetime.now(timezone.utc)})
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():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: elody
3
- Version: 0.0.192
3
+ Version: 0.0.194
4
4
  Summary: elody SDK for Python
5
5
  Author-email: Inuits <developers@inuits.eu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes