diff options
author | Chuck Short <chuck.short@canonical.com> | 2013-10-10 13:20:37 -0400 |
---|---|---|
committer | Chuck Short <chuck.short@canonical.com> | 2013-10-10 14:07:20 -0400 |
commit | b7b31bf64603f021cf4f82241e38c74b5601d48c (patch) | |
tree | f4befc0b01433718f5fdeb7f8e6455b8516784ea | |
parent | 4ae816bbfff7eb3d3bbe63f4e47e40dcb0b9c031 (diff) | |
download | python-keystoneclient-b7b31bf64603f021cf4f82241e38c74b5601d48c.tar.gz |
python3: Make iteritems py3k compat
Use six.iteritems to replace dictionary.iteritems() on python2 or
dictionary.items() on python3.
Change-Id: I972f065414e22d287bd7e00ab2c6e754f17afb75
Signed-off-by: Chuck Short <chuck.short@canonical.com>
-rw-r--r-- | keystoneclient/httpclient.py | 3 | ||||
-rw-r--r-- | keystoneclient/tests/apiclient/test_exceptions.py | 4 | ||||
-rw-r--r-- | keystoneclient/tests/client_fixtures.py | 4 | ||||
-rw-r--r-- | keystoneclient/tests/test_http.py | 5 | ||||
-rw-r--r-- | keystoneclient/utils.py | 3 | ||||
-rw-r--r-- | keystoneclient/v2_0/tenants.py | 6 |
6 files changed, 17 insertions, 8 deletions
diff --git a/keystoneclient/httpclient.py b/keystoneclient/httpclient.py index dc500db..c4a9823 100644 --- a/keystoneclient/httpclient.py +++ b/keystoneclient/httpclient.py @@ -26,6 +26,7 @@ import logging import urlparse import requests +import six try: import keyring @@ -94,7 +95,7 @@ def request(url, method='GET', headers=None, original_ip=None, debug=False, string_parts.append(' %s' % url) if headers: - for header in headers.iteritems(): + for header in six.iteritems(headers): string_parts.append(' -H "%s: %s"' % header) logger.debug("REQ: %s" % "".join(string_parts)) diff --git a/keystoneclient/tests/apiclient/test_exceptions.py b/keystoneclient/tests/apiclient/test_exceptions.py index d41ac02..8141060 100644 --- a/keystoneclient/tests/apiclient/test_exceptions.py +++ b/keystoneclient/tests/apiclient/test_exceptions.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import six + from keystoneclient.apiclient import exceptions from keystoneclient.tests import utils @@ -21,7 +23,7 @@ class FakeResponse(object): json_data = {} def __init__(self, **kwargs): - for key, value in kwargs.iteritems(): + for key, value in six.iteritems(kwargs): setattr(self, key, value) def json(self): diff --git a/keystoneclient/tests/client_fixtures.py b/keystoneclient/tests/client_fixtures.py index dd1c95f..d846ac1 100644 --- a/keystoneclient/tests/client_fixtures.py +++ b/keystoneclient/tests/client_fixtures.py @@ -16,6 +16,8 @@ import os +import six + from keystoneclient.common import cms from keystoneclient.openstack.common import jsonutils from keystoneclient.openstack.common import timeutils @@ -295,4 +297,4 @@ TOKEN_RESPONSES = { JSON_TOKEN_RESPONSES = dict([(k, jsonutils.dumps(v)) for k, v in - TOKEN_RESPONSES.iteritems()]) + six.iteritems(TOKEN_RESPONSES)]) diff --git a/keystoneclient/tests/test_http.py b/keystoneclient/tests/test_http.py index a4b8e8f..2138644 100644 --- a/keystoneclient/tests/test_http.py +++ b/keystoneclient/tests/test_http.py @@ -15,6 +15,7 @@ # under the License. import httpretty +import six import testtools from testtools import matchers @@ -194,10 +195,10 @@ class BasicRequestTests(testtools.TestCase): self.request(headers=headers) - for k, v in headers.iteritems(): + for k, v in six.iteritems(headers): self.assertEqual(httpretty.last_request().headers[k], v) - for header in headers.iteritems(): + for header in six.iteritems(headers): self.assertThat(self.logger.debug_log, matchers.Contains('-H "%s: %s"' % header)) diff --git a/keystoneclient/utils.py b/keystoneclient/utils.py index ae489c8..6902ed3 100644 --- a/keystoneclient/utils.py +++ b/keystoneclient/utils.py @@ -17,6 +17,7 @@ import hashlib import sys import prettytable +import six from keystoneclient import exceptions @@ -74,7 +75,7 @@ def print_dict(d, wrap=0): pt = prettytable.PrettyTable(['Property', 'Value'], caching=False, print_empty=False) pt.aligns = ['l', 'l'] - for (prop, value) in d.iteritems(): + for (prop, value) in six.iteritems(d): if value is None: value = '' value = _word_wrap(value, max_length=wrap) diff --git a/keystoneclient/v2_0/tenants.py b/keystoneclient/v2_0/tenants.py index 6eac981..6b2f5fa 100644 --- a/keystoneclient/v2_0/tenants.py +++ b/keystoneclient/v2_0/tenants.py @@ -16,6 +16,8 @@ import urllib +import six + from keystoneclient import base @@ -81,7 +83,7 @@ class TenantManager(base.ManagerWithFind): "enabled": enabled}} #Allow Extras Passthru and ensure we don't clobber primary arguments. - for k, v in kwargs.iteritems(): + for k, v in six.iteritems(kwargs): if k not in params['tenant']: params['tenant'][k] = v @@ -131,7 +133,7 @@ class TenantManager(base.ManagerWithFind): body['tenant']['description'] = description #Allow Extras Passthru and ensure we don't clobber primary arguments. - for k, v in kwargs.iteritems(): + for k, v in six.iteritems(kwargs): if k not in body['tenant']: body['tenant'][k] = v |