Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -10,6 +10,7 @@ from .comparisons import get_comparison_func
|
|||
|
||||
|
||||
class DynamoJsonEncoder(json.JSONEncoder):
|
||||
|
||||
def default(self, obj):
|
||||
if hasattr(obj, 'to_json'):
|
||||
return obj.to_json()
|
||||
|
|
@ -53,6 +54,7 @@ class DynamoType(object):
|
|||
|
||||
|
||||
class Item(object):
|
||||
|
||||
def __init__(self, hash_key, hash_key_type, range_key, range_key_type, attrs):
|
||||
self.hash_key = hash_key
|
||||
self.hash_key_type = hash_key_type
|
||||
|
|
@ -157,7 +159,8 @@ class Table(object):
|
|||
else:
|
||||
range_value = None
|
||||
|
||||
item = Item(hash_value, self.hash_key_type, range_value, self.range_key_type, item_attrs)
|
||||
item = Item(hash_value, self.hash_key_type, range_value,
|
||||
self.range_key_type, item_attrs)
|
||||
|
||||
if range_value:
|
||||
self.items[hash_value][range_value] = item
|
||||
|
|
@ -167,7 +170,8 @@ class Table(object):
|
|||
|
||||
def get_item(self, hash_key, range_key):
|
||||
if self.has_range_key and not range_key:
|
||||
raise ValueError("Table has a range key, but no range key was passed into get_item")
|
||||
raise ValueError(
|
||||
"Table has a range key, but no range key was passed into get_item")
|
||||
try:
|
||||
if range_key:
|
||||
return self.items[hash_key][range_key]
|
||||
|
|
@ -222,7 +226,8 @@ class Table(object):
|
|||
# Comparison is NULL and we don't have the attribute
|
||||
continue
|
||||
else:
|
||||
# No attribute found and comparison is no NULL. This item fails
|
||||
# No attribute found and comparison is no NULL. This item
|
||||
# fails
|
||||
passes_all_conditions = False
|
||||
break
|
||||
|
||||
|
|
@ -283,7 +288,8 @@ class DynamoDBBackend(BaseBackend):
|
|||
return None, None
|
||||
|
||||
hash_key = DynamoType(hash_key_dict)
|
||||
range_values = [DynamoType(range_value) for range_value in range_value_dicts]
|
||||
range_values = [DynamoType(range_value)
|
||||
for range_value in range_value_dicts]
|
||||
|
||||
return table.query(hash_key, range_comparison, range_values)
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ class DynamoHandler(BaseResponse):
|
|||
throughput = self.body["ProvisionedThroughput"]
|
||||
new_read_units = throughput["ReadCapacityUnits"]
|
||||
new_write_units = throughput["WriteCapacityUnits"]
|
||||
table = dynamodb_backend.update_table_throughput(name, new_read_units, new_write_units)
|
||||
table = dynamodb_backend.update_table_throughput(
|
||||
name, new_read_units, new_write_units)
|
||||
return dynamo_json_dump(table.describe)
|
||||
|
||||
def describe_table(self):
|
||||
|
|
@ -169,7 +170,8 @@ class DynamoHandler(BaseResponse):
|
|||
key = request['Key']
|
||||
hash_key = key['HashKeyElement']
|
||||
range_key = key.get('RangeKeyElement')
|
||||
item = dynamodb_backend.delete_item(table_name, hash_key, range_key)
|
||||
item = dynamodb_backend.delete_item(
|
||||
table_name, hash_key, range_key)
|
||||
|
||||
response = {
|
||||
"Responses": {
|
||||
|
|
@ -221,11 +223,13 @@ class DynamoHandler(BaseResponse):
|
|||
for key in keys:
|
||||
hash_key = key["HashKeyElement"]
|
||||
range_key = key.get("RangeKeyElement")
|
||||
item = dynamodb_backend.get_item(table_name, hash_key, range_key)
|
||||
item = dynamodb_backend.get_item(
|
||||
table_name, hash_key, range_key)
|
||||
if item:
|
||||
item_describe = item.describe_attrs(attributes_to_get)
|
||||
items.append(item_describe)
|
||||
results["Responses"][table_name] = {"Items": items, "ConsumedCapacityUnits": 1}
|
||||
results["Responses"][table_name] = {
|
||||
"Items": items, "ConsumedCapacityUnits": 1}
|
||||
return dynamo_json_dump(results)
|
||||
|
||||
def query(self):
|
||||
|
|
@ -239,7 +243,8 @@ class DynamoHandler(BaseResponse):
|
|||
range_comparison = None
|
||||
range_values = []
|
||||
|
||||
items, last_page = dynamodb_backend.query(name, hash_key, range_comparison, range_values)
|
||||
items, last_page = dynamodb_backend.query(
|
||||
name, hash_key, range_comparison, range_values)
|
||||
|
||||
if items is None:
|
||||
er = 'com.amazonaws.dynamodb.v20111205#ResourceNotFoundException'
|
||||
|
|
@ -265,7 +270,8 @@ class DynamoHandler(BaseResponse):
|
|||
filters = {}
|
||||
scan_filters = self.body.get('ScanFilter', {})
|
||||
for attribute_name, scan_filter in scan_filters.items():
|
||||
# Keys are attribute names. Values are tuples of (comparison, comparison_value)
|
||||
# Keys are attribute names. Values are tuples of (comparison,
|
||||
# comparison_value)
|
||||
comparison_operator = scan_filter["ComparisonOperator"]
|
||||
comparison_values = scan_filter.get("AttributeValueList", [])
|
||||
filters[attribute_name] = (comparison_operator, comparison_values)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue