boto3-assist 0.1.7__py3-none-any.whl → 0.1.9__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.
- boto3_assist/dynamodb/dynamodb_model_base.py +42 -13
- boto3_assist/dynamodb/dynamodb_reserved_words.py +3 -1
- boto3_assist/version.py +1 -1
- {boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/METADATA +1 -1
- {boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/RECORD +8 -8
- {boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/WHEEL +0 -0
- {boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/licenses/LICENSE-EXPLAINED.txt +0 -0
- {boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -153,21 +153,25 @@ class DynamoDBModelBase:
|
|
|
153
153
|
self, include_indexes=include_indexes
|
|
154
154
|
)
|
|
155
155
|
|
|
156
|
-
def to_resource_dictionary(
|
|
156
|
+
def to_resource_dictionary(
|
|
157
|
+
self, include_indexes: bool = True, include_none: bool = False
|
|
158
|
+
):
|
|
157
159
|
"""
|
|
158
160
|
Convert the instance to a dictionary suitable for DynamoDB resource.
|
|
159
161
|
"""
|
|
160
162
|
return DynamoDBSerializer.to_resource_dictionary(
|
|
161
|
-
self, include_indexes=include_indexes
|
|
163
|
+
self, include_indexes=include_indexes, include_none=include_none
|
|
162
164
|
)
|
|
163
165
|
|
|
164
|
-
def to_dictionary(self):
|
|
166
|
+
def to_dictionary(self, include_none: bool = True):
|
|
165
167
|
"""
|
|
166
168
|
Convert the instance to a dictionary without an indexes/keys.
|
|
167
169
|
Usefull for turning an object into a dictionary for serialization.
|
|
168
170
|
This is the same as to_resource_dictionary(include_indexes=False)
|
|
169
171
|
"""
|
|
170
|
-
return DynamoDBSerializer.to_resource_dictionary(
|
|
172
|
+
return DynamoDBSerializer.to_resource_dictionary(
|
|
173
|
+
self, include_indexes=False, include_none=include_none
|
|
174
|
+
)
|
|
171
175
|
|
|
172
176
|
def get_key(self, index_name: str) -> DynamoDBIndex:
|
|
173
177
|
"""Get the index name and key"""
|
|
@@ -232,7 +236,9 @@ class DynamoDBSerializer:
|
|
|
232
236
|
|
|
233
237
|
@staticmethod
|
|
234
238
|
def to_resource_dictionary(
|
|
235
|
-
instance: DynamoDBModelBase,
|
|
239
|
+
instance: DynamoDBModelBase,
|
|
240
|
+
include_indexes: bool = True,
|
|
241
|
+
include_none: bool = False,
|
|
236
242
|
):
|
|
237
243
|
"""
|
|
238
244
|
Convert a Python class instance to a dictionary suitable for DynamoDB resource.
|
|
@@ -244,12 +250,18 @@ class DynamoDBSerializer:
|
|
|
244
250
|
- dict: A dictionary representation of the class instance suitable for DynamoDB resource.
|
|
245
251
|
"""
|
|
246
252
|
return DynamoDBSerializer._serialize(
|
|
247
|
-
instance,
|
|
253
|
+
instance,
|
|
254
|
+
lambda x: x,
|
|
255
|
+
include_indexes=include_indexes,
|
|
256
|
+
include_none=include_none,
|
|
248
257
|
)
|
|
249
258
|
|
|
250
259
|
@staticmethod
|
|
251
260
|
def _serialize(
|
|
252
|
-
instance: DynamoDBModelBase,
|
|
261
|
+
instance: DynamoDBModelBase,
|
|
262
|
+
serialize_fn,
|
|
263
|
+
include_indexes: bool = True,
|
|
264
|
+
include_none: bool = True,
|
|
253
265
|
):
|
|
254
266
|
def is_primitive(value):
|
|
255
267
|
"""Check if the value is a primitive data type."""
|
|
@@ -259,7 +271,11 @@ class DynamoDBSerializer:
|
|
|
259
271
|
"""Serialize the value using the provided function."""
|
|
260
272
|
|
|
261
273
|
if isinstance(value, DynamoDBModelBase):
|
|
262
|
-
return serialize_fn(
|
|
274
|
+
return serialize_fn(
|
|
275
|
+
value.to_resource_dictionary(
|
|
276
|
+
include_indexes=False, include_none=include_none
|
|
277
|
+
)
|
|
278
|
+
)
|
|
263
279
|
if isinstance(value, dt.datetime):
|
|
264
280
|
return serialize_fn(value.isoformat())
|
|
265
281
|
elif isinstance(value, float):
|
|
@@ -278,23 +294,36 @@ class DynamoDBSerializer:
|
|
|
278
294
|
elif isinstance(value, dict):
|
|
279
295
|
return serialize_fn({k: serialize_value(v) for k, v in value.items()})
|
|
280
296
|
else:
|
|
281
|
-
return serialize_fn(
|
|
297
|
+
return serialize_fn(
|
|
298
|
+
DynamoDBSerializer._serialize(
|
|
299
|
+
value,
|
|
300
|
+
serialize_fn,
|
|
301
|
+
include_indexes=include_indexes,
|
|
302
|
+
include_none=include_none,
|
|
303
|
+
)
|
|
304
|
+
)
|
|
282
305
|
|
|
283
|
-
instance_dict = DynamoDBSerializer._add_properties(
|
|
306
|
+
instance_dict = DynamoDBSerializer._add_properties(
|
|
307
|
+
instance, serialize_value, include_none=include_none
|
|
308
|
+
)
|
|
284
309
|
|
|
285
310
|
if include_indexes:
|
|
286
311
|
instance_dict = DynamoDBSerializer._add_indexes(instance, instance_dict)
|
|
287
312
|
return instance_dict
|
|
288
313
|
|
|
289
314
|
@staticmethod
|
|
290
|
-
def _add_properties(
|
|
315
|
+
def _add_properties(
|
|
316
|
+
instance: DynamoDBModelBase,
|
|
317
|
+
serialize_value,
|
|
318
|
+
include_none: bool = True,
|
|
319
|
+
) -> dict:
|
|
291
320
|
instance_dict = {}
|
|
292
321
|
|
|
293
322
|
# Add instance variables
|
|
294
323
|
for attr, value in instance.__dict__.items():
|
|
295
324
|
# don't get the private properties
|
|
296
325
|
if not str(attr).startswith("_"):
|
|
297
|
-
if value is not None:
|
|
326
|
+
if value is not None or include_none:
|
|
298
327
|
instance_dict[attr] = serialize_value(value)
|
|
299
328
|
|
|
300
329
|
# Add properties
|
|
@@ -316,7 +345,7 @@ class DynamoDBSerializer:
|
|
|
316
345
|
# don't get the private properties
|
|
317
346
|
if not str(name).startswith("_"):
|
|
318
347
|
value = getattr(instance, name)
|
|
319
|
-
if value is not None:
|
|
348
|
+
if value is not None or include_none:
|
|
320
349
|
instance_dict[name] = serialize_value(value)
|
|
321
350
|
|
|
322
351
|
return instance_dict
|
boto3_assist/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.1.
|
|
1
|
+
__version__ = '0.1.9'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
boto3_assist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
boto3_assist/boto3session.py,sha256=J20E2lkqJOaey4Ohi-xRe2xABj7QsA8DrggzK29-5es,6415
|
|
3
3
|
boto3_assist/connection_tracker.py,sha256=WYRdDSozJlxbFY_oYQAlGRpDgFWsF_nAiN7CIzh_yVo,2637
|
|
4
|
-
boto3_assist/version.py,sha256=
|
|
4
|
+
boto3_assist/version.py,sha256=2uYVJ4eLF8kKOzfX6k2Go3u7xIwcGSuemAueAoXn-5o,22
|
|
5
5
|
boto3_assist/dynamodb/dynamodb.py,sha256=vV0HvFCESnVK6BcAfcrWsMsNxIIsctvDX_3xdzOVCT0,14623
|
|
6
6
|
boto3_assist/dynamodb/dynamodb_connection.py,sha256=JMCmWOsMzy45rikGl3Z2xqlG2vUTEKSYqi6dpsfJ750,4418
|
|
7
7
|
boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=nTNQ99sIidDoLMhMbBju2umgLmcttsmnvmd_DMy_J9M,1582
|
|
@@ -10,10 +10,10 @@ boto3_assist/dynamodb/dynamodb_importer.py,sha256=nCKsyRQeMqDSf0Q5mQ_X_oVIg4PRnu
|
|
|
10
10
|
boto3_assist/dynamodb/dynamodb_index.py,sha256=LRQgSci222s-pU-JXgnaAoOa71ABX9h3uJPeCVPl1GE,6315
|
|
11
11
|
boto3_assist/dynamodb/dynamodb_iservice.py,sha256=2AuaKxt7DUZbB-GpBBtPtPMpAlgZkumkAldm8vy7-sg,701
|
|
12
12
|
boto3_assist/dynamodb/dynamodb_key.py,sha256=X3I3gUPx2T858vjRDi9SN8qn8ez5UJUo0vZiKBeeUWg,1776
|
|
13
|
-
boto3_assist/dynamodb/dynamodb_model_base.py,sha256=
|
|
13
|
+
boto3_assist/dynamodb/dynamodb_model_base.py,sha256=5JRecZC9Cz8iJ5BZ4b2XhTEMclZB7pAnknrBNzZ3JS4,13350
|
|
14
14
|
boto3_assist/dynamodb/dynamodb_model_base_interfaces.py,sha256=yT4zDRI8vP15WVOHnCvY3FsEy_QSIta5-bnUby70Xow,747
|
|
15
15
|
boto3_assist/dynamodb/dynamodb_reindexer.py,sha256=_I-W7Ply-82fRHnhsRZuquRYxEIXubuWGq7E7B4Pa7I,6204
|
|
16
|
-
boto3_assist/dynamodb/dynamodb_reserved_words.py,sha256=
|
|
16
|
+
boto3_assist/dynamodb/dynamodb_reserved_words.py,sha256=iiud7ijpER5MgKHIP_NIgkDmHVy_57VRQzNHRipv0as,1786
|
|
17
17
|
boto3_assist/dynamodb/dynamodb_reserved_words.txt,sha256=CanugFPh7rpgJ_jH9k4t8ANycrZJWTjT09sWiW4LC68,4137
|
|
18
18
|
boto3_assist/dynamodb/readme.md,sha256=wNMzdRwk0qRV0kE88UUYnJos3pEK0HNjEIVkq2PATf8,1490
|
|
19
19
|
boto3_assist/dynamodb/troubleshooting.md,sha256=uGpBaBUt_MyzjzwFOLOe0udTgcvaOpiTFxfj7ilLNkM,136
|
|
@@ -25,8 +25,8 @@ boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq
|
|
|
25
25
|
boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
boto3_assist/utilities/serialization_utility.py,sha256=s_QQRIhtwIE7xN5nU13mNk2wtWyErBX_Sg7n0gbHj-M,4308
|
|
27
27
|
boto3_assist/utilities/string_utility.py,sha256=w8l063UT3GE48tuJopETyZrjG4CgAzWkyDWMAYMg5Og,7432
|
|
28
|
-
boto3_assist-0.1.
|
|
29
|
-
boto3_assist-0.1.
|
|
30
|
-
boto3_assist-0.1.
|
|
31
|
-
boto3_assist-0.1.
|
|
32
|
-
boto3_assist-0.1.
|
|
28
|
+
boto3_assist-0.1.9.dist-info/METADATA,sha256=T9Z7AqJ3YXzOGdHxwdyccfyiCNf4sE7ZfiV6KZiXbFA,1804
|
|
29
|
+
boto3_assist-0.1.9.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
30
|
+
boto3_assist-0.1.9.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
|
|
31
|
+
boto3_assist-0.1.9.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
|
|
32
|
+
boto3_assist-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
{boto3_assist-0.1.7.dist-info → boto3_assist-0.1.9.dist-info}/licenses/LICENSE-EXPLAINED.txt
RENAMED
|
File without changes
|
|
File without changes
|