Skip to content

Commit

Permalink
py2, py3 compatibility for dict.iteritems
Browse files Browse the repository at this point in the history
  • Loading branch information
nishigori committed Jun 14, 2015
1 parent d14d5ac commit 88a6fc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/dynamodb_dump
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os

import boto
from boto.compat import json
from boto.compat import six


DESCRIPTION = """Dump the contents of one or more DynamoDB tables to the local filesystem.
Expand Down Expand Up @@ -39,7 +40,7 @@ def dump_table(table, out_dir):
for item in table.scan():
# JSON can't serialize sets -- convert those to lists.
data = {}
for k, v in item.iteritems():
for k, v in six.iteritems(item):
if isinstance(v, (set, frozenset)):
data[k] = list(v)
else:
Expand Down
3 changes: 2 additions & 1 deletion bin/dynamodb_load
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import os

import boto
from boto.compat import json
from boto.compat import six
from boto.dynamodb.schema import Schema


Expand Down Expand Up @@ -61,7 +62,7 @@ def load_table(table, in_fd):
for i in _json_iterload(in_fd):
# Convert lists back to sets.
data = {}
for k, v in i.iteritems():
for k, v in six.iteritems(i):
if isinstance(v, list):
data[k] = set(v)
else:
Expand Down
3 changes: 2 additions & 1 deletion bin/elbadmin
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def get(elb, name):

# Make map of all instance Id's to Name tags
import boto
from boto.compat.six import iteritems
if not options.region:
ec2 = boto.connect_ec2()
else:
Expand All @@ -127,7 +128,7 @@ def get(elb, name):
if i.id in instances:
names[i.id] = i.tags.get('Name', '')

name_column_width = max([4] + [len(v) for k,v in names.iteritems()]) + 2
name_column_width = max([4] + [len(v) for k,v in iteritems(names)]) + 2

print "Instances"
print "---------"
Expand Down

0 comments on commit 88a6fc7

Please sign in to comment.