Merge "python3: Refactor dict for python2/python3 compat"

This commit is contained in:
Jenkins
2013-10-16 23:44:20 +00:00
committed by Gerrit Code Review
5 changed files with 6 additions and 6 deletions

View File

@@ -424,7 +424,7 @@ def from_response(response, method, url):
pass
else:
if hasattr(body, "keys"):
error = body[body.keys()[0]]
error = body[list(body)[0]]
kwargs["message"] = error.get("message")
kwargs["details"] = error.get("details")
elif content_type.startswith("text/"):

View File

@@ -428,7 +428,7 @@ class Resource(object):
return self.__dict__[k]
def __repr__(self):
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and
reprkeys = sorted(k for k in self.__dict__ if k[0] != '_' and
k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)

View File

@@ -116,7 +116,7 @@ class Ec2Signer(object):
def _calc_signature_1(self, params):
"""Generate AWS signature version 1 string."""
keys = params.keys()
keys = list(params)
keys.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
for key in keys:
self.hmac.update(key)
@@ -129,7 +129,7 @@ class Ec2Signer(object):
"""Construct a sorted, correctly encoded query string as required for
_calc_signature_2 and _calc_signature_4.
"""
keys = params.keys()
keys = list(params)
keys.sort()
pairs = []
for key in keys:

View File

@@ -141,7 +141,7 @@ class ServiceCatalogV2(ServiceCatalog):
continue
sc[service['type']] = []
for endpoint in service['endpoints']:
if endpoint_type and endpoint_type not in endpoint.keys():
if endpoint_type and endpoint_type not in endpoint:
continue
sc[service['type']].append(endpoint)
return sc

View File

@@ -456,7 +456,7 @@ class OpenStackIdentityShell(object):
options = set()
for sc_str, sc in self.subcommands.items():
commands.add(sc_str)
for option in sc._optionals._option_string_actions.keys():
for option in list(sc._optionals._option_string_actions):
options.add(option)
commands.remove('bash-completion')