boto3-assist 0.1.0__py3-none-any.whl → 0.1.2__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.
@@ -142,24 +142,37 @@ class DynamoDBHelpers:
142
142
  Wraps Up Some usefull information when dealing with
143
143
 
144
144
  """
145
- response: dict[str, List] = {"Items": [], "Batches": []}
145
+ response: dict[str, Any] = {"Items": [], "Batches": []}
146
146
  record_start: int = 0
147
+ total_count = 0
148
+ total_scanned_count = 0
149
+ record_end = 0
147
150
  for item in collection:
148
151
  record_start += 1
149
- record_end = record_start + len(collection)
152
+ record_end = record_end + len(item["Items"])
150
153
  response["Items"].extend(item["Items"])
151
- response["Batches"].append(
152
- {
153
- "LastKey": item["LastKey"],
154
- "Count": item["Count"],
155
- "Scanned": item["Scanned"],
156
- "MoreRecords": item["MoreRecords"],
157
- "Records": {"start": record_start, "end": record_end},
158
- }
159
- )
154
+
155
+ batch: dict[str, Any] = {}
156
+ if "LastEvaluatedKey" in item:
157
+ batch["LastKey"] = item["LastEvaluatedKey"]
158
+
159
+ if "Count" in item:
160
+ batch["Count"] = item["Count"]
161
+ total_count += item["Count"]
162
+
163
+ if "ScannedCount" in item:
164
+ batch["ScannedCount"] = item["ScannedCount"]
165
+ total_scanned_count += item["ScannedCount"]
166
+
167
+ batch["Records"] = {"start": record_start, "end": record_end}
168
+
169
+ response["Batches"].append(batch)
160
170
 
161
171
  record_start = record_end
162
172
 
173
+ response["Count"] = total_count
174
+ response["ScannedCount"] = total_scanned_count
175
+
163
176
  return response
164
177
 
165
178
  @staticmethod
@@ -6,7 +6,7 @@ https://github.com/geekcafe/boto3-assist
6
6
  """
7
7
 
8
8
  from __future__ import annotations
9
- from typing import Optional
9
+ from typing import Optional, Any
10
10
  from boto3.dynamodb.conditions import (
11
11
  ConditionBase,
12
12
  Key,
@@ -110,7 +110,8 @@ class DynamoDBIndex:
110
110
  *,
111
111
  include_sort_key: bool = True,
112
112
  condition: str = "begins_with",
113
- high_value: Optional[DynamoDBKey] = None,
113
+ low_value: Any = None,
114
+ high_value: Any = None,
114
115
  # sk_value_2: Optional[str | int | float] = None,
115
116
  ) -> dict | Key | ConditionBase | ComparisonCondition | Equals:
116
117
  """Get the key for a given index"""
@@ -129,6 +130,7 @@ class DynamoDBIndex:
129
130
  key = self._build_query_key(
130
131
  include_sort_key=include_sort_key,
131
132
  condition=condition,
133
+ low_value=low_value,
132
134
  high_value=high_value,
133
135
  )
134
136
  return key
@@ -138,7 +140,8 @@ class DynamoDBIndex:
138
140
  *,
139
141
  include_sort_key: bool = True,
140
142
  condition: str = "begins_with",
141
- high_value: Optional[DynamoDBKey] = None,
143
+ low_value: Any = None,
144
+ high_value: Any = None,
142
145
  ) -> And | Equals:
143
146
  """Get the GSI index name and key"""
144
147
 
@@ -146,13 +149,22 @@ class DynamoDBIndex:
146
149
  self.partition_key.value
147
150
  )
148
151
 
149
- if include_sort_key and self.sort_key.attribute_name and self.sort_key.value:
152
+ if (
153
+ include_sort_key
154
+ and self.sort_key.attribute_name
155
+ and (
156
+ self.sort_key.value
157
+ or (low_value is not None and high_value is not None)
158
+ )
159
+ ):
150
160
  # if self.sk_value_2:
151
- if high_value:
161
+ if low_value is not None and high_value is not None:
152
162
  match condition:
153
163
  case "between":
164
+ low = f"{self.sort_key.value}{low_value}"
165
+ high = f"{self.sort_key.value}{high_value}"
154
166
  key = key & Key(f"{self.sort_key.attribute_name}").between(
155
- self.sort_key.value, high_value.value
167
+ low, high
156
168
  )
157
169
 
158
170
  else:
@@ -53,9 +53,10 @@ class DynamoDBKey:
53
53
  """
54
54
  parts = []
55
55
  for key, value in key_value_pairs:
56
+ prefix = f"{key}#" if key else ""
56
57
  if value is None:
57
- parts.append(f"{key}#")
58
+ parts.append(f"{prefix}")
58
59
  break
59
60
  else:
60
- parts.append(f"{key}#{value}")
61
+ parts.append(f"{prefix}{value}")
61
62
  return "#".join(parts)
boto3_assist/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.1.0'
1
+ __version__ = '0.1.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
@@ -40,7 +40,7 @@ environment vars first and then load your session.
40
40
 
41
41
  ## DyamoDB model mapping and Key Generation
42
42
  It's a light weight mapping tool to turn your python classes / object models to DynamoDB items that are ready
43
- for saving. See the examples directory for more information.
43
+ for saving. See the [examples](https://github.com/geekcafe/boto3-assist/tree/main/examples) directory in the repo for more information.
44
44
 
45
45
 
46
46
  ```sh
@@ -1,14 +1,14 @@
1
1
  boto3_assist/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  boto3_assist/boto3session.py,sha256=J20E2lkqJOaey4Ohi-xRe2xABj7QsA8DrggzK29-5es,6415
3
- boto3_assist/version.py,sha256=IMjkMO3twhQzluVTo8Z6rE7Eg-9U79_LGKMcsWLKBkY,22
3
+ boto3_assist/version.py,sha256=mdp2CftfqYbdKtP-eWv1z7rAUycYv6X1ntXSMUf8Kss,22
4
4
  boto3_assist/dynamodb/dynamodb.py,sha256=jU4R__5jjI1CmH9xVNUeU8PICD2dtbQ2CYUFKMRw0P0,14561
5
5
  boto3_assist/dynamodb/dynamodb_connection.py,sha256=JMCmWOsMzy45rikGl3Z2xqlG2vUTEKSYqi6dpsfJ750,4418
6
6
  boto3_assist/dynamodb/dynamodb_connection_tracker.py,sha256=nTNQ99sIidDoLMhMbBju2umgLmcttsmnvmd_DMy_J9M,1582
7
- boto3_assist/dynamodb/dynamodb_helpers.py,sha256=LsoNixhinEwBT7hgWc7hT-5I2qdvEAiF59ZVb19jA7Y,11833
7
+ boto3_assist/dynamodb/dynamodb_helpers.py,sha256=ajpTJ5bJOm9PDgE2Zx9p2zkTRFV4xswqJRS81SOTn1s,12198
8
8
  boto3_assist/dynamodb/dynamodb_importer.py,sha256=8SlT2W03Dvb3LIs6xqtzXP4IShyv655PgMCDNr4kmPk,2559
9
- boto3_assist/dynamodb/dynamodb_index.py,sha256=Uw2MmFivLp8VwDc3sNWgifc0yUvDcZD1TNawqvioi_8,5953
9
+ boto3_assist/dynamodb/dynamodb_index.py,sha256=LRQgSci222s-pU-JXgnaAoOa71ABX9h3uJPeCVPl1GE,6315
10
10
  boto3_assist/dynamodb/dynamodb_iservice.py,sha256=2AuaKxt7DUZbB-GpBBtPtPMpAlgZkumkAldm8vy7-sg,701
11
- boto3_assist/dynamodb/dynamodb_key.py,sha256=HInymjT-NyJb21fuXnvFMxBBLr2HA4O8XOUSsU5Te1w,1726
11
+ boto3_assist/dynamodb/dynamodb_key.py,sha256=X3I3gUPx2T858vjRDi9SN8qn8ez5UJUo0vZiKBeeUWg,1776
12
12
  boto3_assist/dynamodb/dynamodb_model_base.py,sha256=B8E4D2btjcIJjpzDnULlQk5Ccp5Qp3vN8vRdUHlshns,10949
13
13
  boto3_assist/dynamodb/dynamodb_model_base_interfaces.py,sha256=yT4zDRI8vP15WVOHnCvY3FsEy_QSIta5-bnUby70Xow,747
14
14
  boto3_assist/dynamodb/dynamodb_reindexer.py,sha256=_I-W7Ply-82fRHnhsRZuquRYxEIXubuWGq7E7B4Pa7I,6204
@@ -21,8 +21,8 @@ boto3_assist/utilities/datetime_utility.py,sha256=TbqGQkJDTahqvaZAIV550nhYnW1Bsq
21
21
  boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  boto3_assist/utilities/serialization_utility.py,sha256=s_QQRIhtwIE7xN5nU13mNk2wtWyErBX_Sg7n0gbHj-M,4308
23
23
  boto3_assist/utilities/string_utility.py,sha256=w8l063UT3GE48tuJopETyZrjG4CgAzWkyDWMAYMg5Og,7432
24
- boto3_assist-0.1.0.dist-info/METADATA,sha256=XqXrX9CBBG0trJGOs5W_AZ33u_1ccmEH6ddLt6-wyHc,1729
25
- boto3_assist-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
26
- boto3_assist-0.1.0.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
27
- boto3_assist-0.1.0.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
28
- boto3_assist-0.1.0.dist-info/RECORD,,
24
+ boto3_assist-0.1.2.dist-info/METADATA,sha256=m3h0jNmaoYo8ji85NGE8Bm5s6nss7Z8CsqyJMmBsf78,1804
25
+ boto3_assist-0.1.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
26
+ boto3_assist-0.1.2.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
27
+ boto3_assist-0.1.2.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
28
+ boto3_assist-0.1.2.dist-info/RECORD,,