Linting
This commit is contained in:
parent
caebe222d7
commit
71d3941daf
2 changed files with 199 additions and 250 deletions
|
|
@ -833,7 +833,7 @@ class DynamoHandler(BaseResponse):
|
|||
return json.dumps({"TimeToLiveDescription": ttl_spec})
|
||||
|
||||
def transact_get_items(self):
|
||||
transact_items = self.body['TransactItems']
|
||||
transact_items = self.body["TransactItems"]
|
||||
responses = list()
|
||||
|
||||
if len(transact_items) > TRANSACTION_MAX_ITEMS:
|
||||
|
|
@ -842,26 +842,32 @@ class DynamoHandler(BaseResponse):
|
|||
request_id = 268435456
|
||||
for _ in transact_items:
|
||||
request_id += 1
|
||||
hex_request_id = format(request_id, 'x')
|
||||
err_list.append('com.amazonaws.dynamodb.v20120810.TransactGetItem@%s' % hex_request_id)
|
||||
msg += ', '.join(err_list)
|
||||
msg += "'] at 'transactItems' failed to satisfy constraint: " \
|
||||
"Member must have length less than or equal to %s" % TRANSACTION_MAX_ITEMS
|
||||
hex_request_id = format(request_id, "x")
|
||||
err_list.append(
|
||||
"com.amazonaws.dynamodb.v20120810.TransactGetItem@%s"
|
||||
% hex_request_id
|
||||
)
|
||||
msg += ", ".join(err_list)
|
||||
msg += (
|
||||
"'] at 'transactItems' failed to satisfy constraint: "
|
||||
"Member must have length less than or equal to %s"
|
||||
% TRANSACTION_MAX_ITEMS
|
||||
)
|
||||
|
||||
return self.error('ValidationException', msg)
|
||||
return self.error("ValidationException", msg)
|
||||
|
||||
ret_consumed_capacity = self.body.get('ReturnConsumedCapacity', 'NONE')
|
||||
ret_consumed_capacity = self.body.get("ReturnConsumedCapacity", "NONE")
|
||||
consumed_capacity = dict()
|
||||
|
||||
for transact_item in transact_items:
|
||||
|
||||
table_name = transact_item['Get']['TableName']
|
||||
key = transact_item['Get']['Key']
|
||||
table_name = transact_item["Get"]["TableName"]
|
||||
key = transact_item["Get"]["Key"]
|
||||
try:
|
||||
item = self.dynamodb_backend.get_item(table_name, key)
|
||||
except ValueError:
|
||||
er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException'
|
||||
return self.error(er, 'Requested resource not found')
|
||||
er = "com.amazonaws.dynamodb.v20111205#ResourceNotFoundException"
|
||||
return self.error(er, "Requested resource not found")
|
||||
|
||||
if not item:
|
||||
continue
|
||||
|
|
@ -870,25 +876,22 @@ class DynamoHandler(BaseResponse):
|
|||
responses.append(item_describe)
|
||||
|
||||
table_capacity = consumed_capacity.get(table_name, {})
|
||||
table_capacity['TableName'] = table_name
|
||||
capacity_units = table_capacity.get('CapacityUnits', 0) + 2.0
|
||||
table_capacity['CapacityUnits'] = capacity_units
|
||||
read_capacity_units = table_capacity.get('ReadCapacityUnits', 0) + 2.0
|
||||
table_capacity['ReadCapacityUnits'] = read_capacity_units
|
||||
table_capacity["TableName"] = table_name
|
||||
capacity_units = table_capacity.get("CapacityUnits", 0) + 2.0
|
||||
table_capacity["CapacityUnits"] = capacity_units
|
||||
read_capacity_units = table_capacity.get("ReadCapacityUnits", 0) + 2.0
|
||||
table_capacity["ReadCapacityUnits"] = read_capacity_units
|
||||
consumed_capacity[table_name] = table_capacity
|
||||
|
||||
if ret_consumed_capacity == 'INDEXES':
|
||||
table_capacity['Table'] = {
|
||||
'CapacityUnits': capacity_units,
|
||||
'ReadCapacityUnits': read_capacity_units
|
||||
if ret_consumed_capacity == "INDEXES":
|
||||
table_capacity["Table"] = {
|
||||
"CapacityUnits": capacity_units,
|
||||
"ReadCapacityUnits": read_capacity_units,
|
||||
}
|
||||
|
||||
result = dict()
|
||||
result.update({
|
||||
'Responses': responses})
|
||||
if ret_consumed_capacity != 'NONE':
|
||||
result.update({
|
||||
'ConsumedCapacity': [v for v in consumed_capacity.values()]
|
||||
})
|
||||
result.update({"Responses": responses})
|
||||
if ret_consumed_capacity != "NONE":
|
||||
result.update({"ConsumedCapacity": [v for v in consumed_capacity.values()]})
|
||||
|
||||
return dynamo_json_dump(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue