Support Python 3 using six
This commit is contained in:
parent
d653a3a3f7
commit
eedb4c4b73
67 changed files with 455 additions and 255 deletions
|
|
@ -31,8 +31,8 @@ class DynamoType(object):
|
|||
"""
|
||||
|
||||
def __init__(self, type_as_dict):
|
||||
self.type = type_as_dict.keys()[0]
|
||||
self.value = type_as_dict.values()[0]
|
||||
self.type = list(type_as_dict.keys())[0]
|
||||
self.value = list(type_as_dict.values())[0]
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.type, self.value))
|
||||
|
|
@ -66,7 +66,7 @@ class Item(object):
|
|||
self.range_key_type = range_key_type
|
||||
|
||||
self.attrs = {}
|
||||
for key, value in attrs.iteritems():
|
||||
for key, value in attrs.items():
|
||||
self.attrs[key] = DynamoType(value)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
@ -74,7 +74,7 @@ class Item(object):
|
|||
|
||||
def to_json(self):
|
||||
attributes = {}
|
||||
for attribute_key, attribute in self.attrs.iteritems():
|
||||
for attribute_key, attribute in self.attrs.items():
|
||||
attributes[attribute_key] = attribute.value
|
||||
|
||||
return {
|
||||
|
|
@ -84,7 +84,7 @@ class Item(object):
|
|||
def describe_attrs(self, attributes):
|
||||
if attributes:
|
||||
included = {}
|
||||
for key, value in self.attrs.iteritems():
|
||||
for key, value in self.attrs.items():
|
||||
if key in attributes:
|
||||
included[key] = value
|
||||
else:
|
||||
|
|
@ -143,7 +143,7 @@ class Table(object):
|
|||
|
||||
def __len__(self):
|
||||
count = 0
|
||||
for key, value in self.items.iteritems():
|
||||
for key, value in self.items.items():
|
||||
if self.has_range_key:
|
||||
count += len(value)
|
||||
else:
|
||||
|
|
@ -213,7 +213,7 @@ class Table(object):
|
|||
for result in self.all_items():
|
||||
scanned_count += 1
|
||||
passes_all_conditions = True
|
||||
for attribute_name, (comparison_operator, comparison_objs) in filters.iteritems():
|
||||
for attribute_name, (comparison_operator, comparison_objs) in filters.items():
|
||||
attribute = result.attrs.get(attribute_name)
|
||||
|
||||
if attribute:
|
||||
|
|
@ -296,7 +296,7 @@ class DynamoDBBackend(BaseBackend):
|
|||
return None, None, None
|
||||
|
||||
scan_filters = {}
|
||||
for key, (comparison_operator, comparison_values) in filters.iteritems():
|
||||
for key, (comparison_operator, comparison_values) in filters.items():
|
||||
dynamo_types = [DynamoType(value) for value in comparison_values]
|
||||
scan_filters[key] = (comparison_operator, dynamo_types)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue