boto3-assist 0.1.8__tar.gz → 0.1.9__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 (80) hide show
  1. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/PKG-INFO +1 -1
  2. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/pyproject.toml +1 -1
  3. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_model_base.py +42 -13
  4. boto3_assist-0.1.9/src/boto3_assist/version.py +1 -0
  5. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/dynamodb_model_projections_test.py +9 -0
  6. boto3_assist-0.1.8/src/boto3_assist/version.py +0 -1
  7. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.env.development +0 -0
  8. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.env.docker +0 -0
  9. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.env.docker.001 +0 -0
  10. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.env.docker.nosql.workbench +0 -0
  11. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.gitignore +0 -0
  12. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.vscode/launch.json +0 -0
  13. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.vscode/settings.json +0 -0
  14. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/.vscode/tasks.json +0 -0
  15. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/LICENSE-EXPLAINED.txt +0 -0
  16. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/LICENSE.txt +0 -0
  17. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/README.md +0 -0
  18. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/aws_regions_with_status.csv +0 -0
  19. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/aws_regions_with_status.json +0 -0
  20. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/devops/build.py +0 -0
  21. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/devops/readme.md +0 -0
  22. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/__init__.py +0 -0
  23. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/models/order_item_model.py +0 -0
  24. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/models/order_model.py +0 -0
  25. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/models/product_model.py +0 -0
  26. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/models/user_model.py +0 -0
  27. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/models/user_post_model.py +0 -0
  28. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/order_example/main.py +0 -0
  29. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/order_example/products.json +0 -0
  30. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/order_item_service.py +0 -0
  31. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/order_service.py +0 -0
  32. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/product_service.py +0 -0
  33. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/table_service.py +0 -0
  34. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/user_post_service.py +0 -0
  35. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/user_service.py +0 -0
  36. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/user_service_client_example.py +0 -0
  37. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/services/user_service_resource_example.py +0 -0
  38. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/dynamodb/user_post_example/main.py +0 -0
  39. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/examples/ec2/regions_report.py +0 -0
  40. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/module-headers.txt +0 -0
  41. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/mypy.ini +0 -0
  42. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/requirements-dev.txt +0 -0
  43. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/requirements.txt +0 -0
  44. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/run-checks.sh +0 -0
  45. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/__init__.py +0 -0
  46. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/boto3session.py +0 -0
  47. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/connection_tracker.py +0 -0
  48. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb.py +0 -0
  49. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_connection.py +0 -0
  50. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_connection_tracker.py +0 -0
  51. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_helpers.py +0 -0
  52. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_importer.py +0 -0
  53. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_index.py +0 -0
  54. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_iservice.py +0 -0
  55. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_key.py +0 -0
  56. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_model_base_interfaces.py +0 -0
  57. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_reindexer.py +0 -0
  58. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_reserved_words.py +0 -0
  59. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/dynamodb_reserved_words.txt +0 -0
  60. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/readme.md +0 -0
  61. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/dynamodb/troubleshooting.md +0 -0
  62. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/ec2/ec2_connection.py +0 -0
  63. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/environment_services/__init__.py +0 -0
  64. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/environment_services/environment_loader.py +0 -0
  65. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/environment_services/environment_variables.py +0 -0
  66. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/utilities/datetime_utility.py +0 -0
  67. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/utilities/logging_utility.py +0 -0
  68. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/utilities/serialization_utility.py +0 -0
  69. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/src/boto3_assist/utilities/string_utility.py +0 -0
  70. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/__init__.py +0 -0
  71. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/__top/__init__.py +0 -0
  72. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/__init__.py +0 -0
  73. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/dynamodb_model_base_test.py +0 -0
  74. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/dynamodb_reindex_test.py +0 -0
  75. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/models/simple_model.py +0 -0
  76. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/dynamodb/models/user_model.py +0 -0
  77. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/examples_test/__init__.py +0 -0
  78. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/examples_test/user_service_test.py +0 -0
  79. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/utilities/__init__.py +0 -0
  80. {boto3_assist-0.1.8 → boto3_assist-0.1.9}/tests/utilities/serialization_utility_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Additional boto3 wrappers to make your life a little easier
5
5
  Author-email: Eric Wilson <boto3-assist@geekcafe.com>
6
6
  License-File: LICENSE-EXPLAINED.txt
@@ -7,7 +7,7 @@ packages = ["src/boto3_assist"]
7
7
 
8
8
  [project]
9
9
  name = "boto3_assist"
10
- version = "0.1.8"
10
+ version = "0.1.9"
11
11
  authors = [
12
12
  { name="Eric Wilson", email="boto3-assist@geekcafe.com" }
13
13
  ]
@@ -153,21 +153,25 @@ class DynamoDBModelBase:
153
153
  self, include_indexes=include_indexes
154
154
  )
155
155
 
156
- def to_resource_dictionary(self, include_indexes: bool = True):
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(self, include_indexes=False)
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, include_indexes: bool = True
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, lambda x: x, include_indexes=include_indexes
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, serialize_fn, include_indexes: bool = True
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(value.to_resource_dictionary(False))
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(DynamoDBSerializer._serialize(value, 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(instance, serialize_value)
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(instance: DynamoDBModelBase, serialize_value) -> dict:
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
@@ -0,0 +1 @@
1
+ __version__ = '0.1.9'
@@ -80,3 +80,12 @@ class DynamoDBModeProjectionlUnitTest(unittest.TestCase):
80
80
 
81
81
  attribute_names = model.projection_expression_attribute_names
82
82
  self.assertIsNone(attribute_names)
83
+
84
+ def test_user_model_and_nulls(self):
85
+ model: User = User()
86
+ model.first_name = "John"
87
+
88
+ expressions = model.projection_expression
89
+ self.assertIsInstance(expressions, str)
90
+
91
+ self.assertIn("id", expressions)
@@ -1 +0,0 @@
1
- __version__ = '0.1.8'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes