python3: Compatibility for iteritems differences
In python3 dict.iteritems(), dict.iterkeys(), and dict.itervalues() are no longer supported. So use six.iteritems() where it is appropriate. Change-Id: I8b07dc2a89d790ec275d45f859e1644e9b00c837 Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
parent
05ca996e67
commit
a25d4fe59a
@ -17,6 +17,8 @@
|
||||
import logging
|
||||
import pkg_resources
|
||||
|
||||
import six
|
||||
|
||||
from novaclient import exceptions
|
||||
from novaclient import utils
|
||||
|
||||
@ -49,7 +51,7 @@ def load_auth_system_opts(parser):
|
||||
This function will try to populate the parser with options from the
|
||||
available plugins.
|
||||
"""
|
||||
for name, auth_plugin in _discovered_plugins.iteritems():
|
||||
for name, auth_plugin in six.iteritems(_discovered_plugins):
|
||||
add_opts_fn = getattr(auth_plugin, "add_opts", None)
|
||||
if add_opts_fn:
|
||||
group = parser.add_argument_group("Auth-system '%s' options" %
|
||||
|
@ -23,6 +23,9 @@ import abc
|
||||
import contextlib
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
from novaclient import exceptions
|
||||
from novaclient import utils
|
||||
|
||||
@ -315,7 +318,7 @@ class Resource(object):
|
||||
return None
|
||||
|
||||
def _add_details(self, info):
|
||||
for (k, v) in info.iteritems():
|
||||
for (k, v) in six.iteritems(info):
|
||||
try:
|
||||
setattr(self, k, v)
|
||||
self._info[k] = v
|
||||
|
@ -6,6 +6,7 @@ import textwrap
|
||||
import uuid
|
||||
|
||||
import prettytable
|
||||
import six
|
||||
|
||||
from novaclient import exceptions
|
||||
from novaclient.openstack.common import strutils
|
||||
@ -172,7 +173,7 @@ def print_list(objs, fields, formatters={}, sortby_index=None):
|
||||
def print_dict(d, dict_property="Property", dict_value="Value", wrap=0):
|
||||
pt = prettytable.PrettyTable([dict_property, dict_value], caching=False)
|
||||
pt.align = 'l'
|
||||
for k, v in d.iteritems():
|
||||
for k, v in six.iteritems(d):
|
||||
# convert dict to str to check length
|
||||
if isinstance(v, dict):
|
||||
v = str(v)
|
||||
|
@ -19,6 +19,8 @@ Security group interface (1.1 extension).
|
||||
|
||||
import urllib
|
||||
|
||||
import six
|
||||
|
||||
from novaclient import base
|
||||
|
||||
|
||||
@ -87,7 +89,7 @@ class SecurityGroupManager(base.ManagerWithFind):
|
||||
"""
|
||||
search_opts = search_opts or {}
|
||||
|
||||
qparams = dict((k, v) for (k, v) in search_opts.iteritems() if v)
|
||||
qparams = dict((k, v) for (k, v) in six.iteritems(search_opts) if v)
|
||||
|
||||
query_string = '?%s' % urllib.urlencode(qparams) if qparams else ''
|
||||
|
||||
|
@ -21,6 +21,8 @@ Server interface.
|
||||
|
||||
import urllib
|
||||
|
||||
import six
|
||||
|
||||
from novaclient import base
|
||||
from novaclient import crypto
|
||||
from novaclient.v1_1 import base as local_base
|
||||
@ -365,7 +367,7 @@ class ServerManager(local_base.BootingManagerWithFind):
|
||||
|
||||
qparams = {}
|
||||
|
||||
for opt, val in search_opts.iteritems():
|
||||
for opt, val in six.iteritems(search_opts):
|
||||
if val:
|
||||
qparams[opt] = val
|
||||
|
||||
|
@ -19,6 +19,8 @@ Volume interface (1.1 extension).
|
||||
|
||||
import urllib
|
||||
|
||||
import six
|
||||
|
||||
from novaclient import base
|
||||
|
||||
|
||||
@ -86,7 +88,7 @@ class VolumeManager(base.ManagerWithFind):
|
||||
"""
|
||||
search_opts = search_opts or {}
|
||||
|
||||
qparams = dict((k, v) for (k, v) in search_opts.iteritems() if v)
|
||||
qparams = dict((k, v) for (k, v) in six.iteritems(search_opts) if v)
|
||||
|
||||
query_string = '?%s' % urllib.urlencode(qparams) if qparams else ''
|
||||
|
||||
|
@ -5,3 +5,4 @@ iso8601>=0.1.4
|
||||
prettytable>=0.6,<0.8
|
||||
requests>=0.8
|
||||
simplejson
|
||||
six
|
||||
|
Loading…
Reference in New Issue
Block a user