Use six.iteritems() for dict

In Python 3, dict.iteritems() is not supported anymore.

Partial implement: blueprint py33-support

Change-Id: Iec357ce5c5a6d2ffe4085bf26569a926e92e735a
This commit is contained in:
Kui Shi
2013-10-16 05:29:06 +08:00
parent acbe15cbd1
commit 8fa5e71b47
2 changed files with 4 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ Base utilities to build API operation managers and objects on top of.
"""
import copy
import six
# Python 2.4 compat
@@ -95,7 +96,7 @@ class Resource(object):
self._loaded = loaded
def _add_details(self, info):
for (k, v) in info.iteritems():
for (k, v) in six.iteritems(info):
setattr(self, k, v)
def __getattr__(self, k):

View File

@@ -17,6 +17,7 @@ from __future__ import print_function
import argparse
import os
import six
import sys
import textwrap
import uuid
@@ -103,7 +104,7 @@ def print_dict(d, dict_property="Property", wrap=0):
pt = prettytable.PrettyTable([dict_property, 'Value'],
caching=False, print_empty=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)