Support Python 3 using six
This commit is contained in:
parent
d653a3a3f7
commit
eedb4c4b73
67 changed files with 455 additions and 255 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
import json
|
||||
import six
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from moto.core.utils import camelcase_to_underscores
|
||||
|
|
@ -50,15 +51,16 @@ class DynamoHandler(BaseResponse):
|
|||
return status, self.response_headers, dynamo_json_dump({'__type': type_})
|
||||
|
||||
def call_action(self):
|
||||
if 'GetSessionToken' in self.body:
|
||||
body = self.body.decode('utf-8')
|
||||
if 'GetSessionToken' in body:
|
||||
return 200, self.response_headers, sts_handler()
|
||||
|
||||
self.body = json.loads(self.body or '{}')
|
||||
self.body = json.loads(body or '{}')
|
||||
endpoint = self.get_endpoint_name(self.headers)
|
||||
if endpoint:
|
||||
endpoint = camelcase_to_underscores(endpoint)
|
||||
response = getattr(self, endpoint)()
|
||||
if isinstance(response, basestring):
|
||||
if isinstance(response, six.string_types):
|
||||
return 200, self.response_headers, response
|
||||
|
||||
else:
|
||||
|
|
@ -73,10 +75,10 @@ class DynamoHandler(BaseResponse):
|
|||
limit = body.get('Limit')
|
||||
if body.get("ExclusiveStartTableName"):
|
||||
last = body.get("ExclusiveStartTableName")
|
||||
start = dynamodb_backend.tables.keys().index(last) + 1
|
||||
start = list(dynamodb_backend.tables.keys()).index(last) + 1
|
||||
else:
|
||||
start = 0
|
||||
all_tables = dynamodb_backend.tables.keys()
|
||||
all_tables = list(dynamodb_backend.tables.keys())
|
||||
if limit:
|
||||
tables = all_tables[start:start + limit]
|
||||
else:
|
||||
|
|
@ -155,7 +157,7 @@ class DynamoHandler(BaseResponse):
|
|||
def batch_write_item(self):
|
||||
table_batches = self.body['RequestItems']
|
||||
|
||||
for table_name, table_requests in table_batches.iteritems():
|
||||
for table_name, table_requests in table_batches.items():
|
||||
for table_request in table_requests:
|
||||
request_type = table_request.keys()[0]
|
||||
request = table_request.values()[0]
|
||||
|
|
@ -212,7 +214,7 @@ class DynamoHandler(BaseResponse):
|
|||
}
|
||||
}
|
||||
|
||||
for table_name, table_request in table_batches.iteritems():
|
||||
for table_name, table_request in table_batches.items():
|
||||
items = []
|
||||
keys = table_request['Keys']
|
||||
attributes_to_get = table_request.get('AttributesToGet')
|
||||
|
|
@ -262,7 +264,7 @@ class DynamoHandler(BaseResponse):
|
|||
|
||||
filters = {}
|
||||
scan_filters = self.body.get('ScanFilter', {})
|
||||
for attribute_name, scan_filter in scan_filters.iteritems():
|
||||
for attribute_name, scan_filter in scan_filters.items():
|
||||
# Keys are attribute names. Values are tuples of (comparison, comparison_value)
|
||||
comparison_operator = scan_filter["ComparisonOperator"]
|
||||
comparison_values = scan_filter.get("AttributeValueList", [])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue