Commit c477796f authored by rajat29's avatar rajat29 Committed by Pierre Riteau

Replace six.iteritems() with .items()

As mentioned in [1], we should avoid using six.iteritems() to achieve
iterators. We can use dict.items() instead, as it will return iterators
in Python 3 as well, and it is more readable.

In Python 2, the overhead of dict.items() creating a new list should be
negligible for most use cases in OpenStack [2].


Change-Id: I620c9cc201c62f033a5467aa52625b56e19933cb
parent dddc60b8
......@@ -84,7 +84,7 @@ class BlazarCommand(OpenStackCommand):
return parser
def format_output_data(self, data):
for k, v in six.iteritems(data):
for k, v in data.items():
if isinstance(v, six.text_type):
# Deserialize if possible into dict, lists, tuples...
......@@ -134,7 +134,7 @@ class CreateCommand(BlazarCommand, show.ShowOne):
print(, 'Created a new %s:' % self.resource)
data = {'': ''}
return zip(*sorted(six.iteritems(data)))
return zip(*sorted(data.items()))
class UpdateCommand(BlazarCommand):
......@@ -291,4 +291,4 @@ class ShowCommand(BlazarCommand, show.ShowOne):
resource_manager = getattr(blazar_client, self.resource)
data = resource_manager.get(res_id)
return zip(*sorted(six.iteritems(data)))
return zip(*sorted(data.items()))
......@@ -17,7 +17,6 @@ import datetime
import json
import os
import re
import six
from blazarclient import exception
from blazarclient.i18n import _
......@@ -52,13 +51,13 @@ def to_primitive(value):
return o
elif isinstance(value, dict):
o = {}
for k, v in six.iteritems(value):
for k, v in value.items():
o[k] = to_primitive(v)
return o
elif isinstance(value, datetime.datetime):
return str(value)
elif hasattr(value, 'iteritems'):
return to_primitive(dict(six.iteritems(value)))
return to_primitive(dict(value.items()))
elif hasattr(value, '__iter__'):
return to_primitive(list(value))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment