From 02b00b6226436b0049e226e86210ed1c1cad53c6 Mon Sep 17 00:00:00 2001 From: Yassine Lamgarchal Date: Fri, 10 Jan 2014 11:13:21 +0100 Subject: Python 3: use six.iteritems and six.string_types six.iteritems() replaces dictionary.iteritems() on Python 2 and dictionary.items() on Python 3. six.string_types replaces basestring() in Python 2 and str in Python 3. Change-Id: Ia18510d167df35caec83626718010228e2140bc0 --- glanceclient/common/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'glanceclient/common/utils.py') diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 0120572..4aec25d 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -20,6 +20,8 @@ import os import sys import uuid +import six + if os.name == 'nt': import msvcrt else: @@ -63,7 +65,7 @@ def schema_args(schema_getter, omit=[]): kwargs)) else: properties = schema.get('properties', {}) - for name, property in properties.iteritems(): + for name, property in six.iteritems(properties): if name in omit: continue param = '--' + name.replace('_', '-') @@ -123,7 +125,7 @@ def print_dict(d, max_column_width=80): pt = prettytable.PrettyTable(['Property', 'Value'], caching=False) pt.align = 'l' pt.max_width = max_column_width - [pt.add_row(list(r)) for r in d.iteritems()] + [pt.add_row(list(r)) for r in six.iteritems(d)] print(strutils.safe_encode(pt.get_string(sortby='Property'))) -- cgit v1.2.1