Replace six.iteritems() with .items()
1.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 PY3 as well. And dict.items/keys will more readable. 2.In py2, the performance about list should be negligible, see the link [2]. [1] https://wiki.openstack.org/wiki/Python3 [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I225da4f95187387007df11c91047497a2a93e862
This commit is contained in:
parent
68437adb7b
commit
edc19a290b
|
@ -25,7 +25,6 @@ import math
|
|||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import units
|
||||
import six
|
||||
from six.moves import urllib
|
||||
|
||||
from glance_store import capabilities
|
||||
|
@ -162,7 +161,7 @@ class StoreLocation(location.StoreLocation):
|
|||
|
||||
def process_specs(self):
|
||||
# convert to ascii since librbd doesn't handle unicode
|
||||
for key, value in six.iteritems(self.specs):
|
||||
for key, value in self.specs.items():
|
||||
self.specs[key] = str(value)
|
||||
self.fsid = self.specs.get('fsid')
|
||||
self.pool = self.specs.get('pool')
|
||||
|
|
|
@ -500,7 +500,7 @@ class Store(glance_store.Store):
|
|||
|
||||
def select_datastore(self, image_size):
|
||||
"""Select a datastore with free space larger than image size."""
|
||||
for k, v in sorted(six.iteritems(self.datastores), reverse=True):
|
||||
for k, v in sorted(self.datastores.items(), reverse=True):
|
||||
max_ds = None
|
||||
max_fs = 0
|
||||
for ds in v:
|
||||
|
|
|
@ -20,7 +20,6 @@ import shutil
|
|||
import fixtures
|
||||
from oslo_config import cfg
|
||||
from oslotest import base
|
||||
import six
|
||||
|
||||
import glance_store as store
|
||||
from glance_store import location
|
||||
|
@ -67,7 +66,7 @@ class StoreBaseTest(base.BaseTestCase):
|
|||
test by the fixtures cleanup process.
|
||||
"""
|
||||
group = kw.pop('group', 'glance_store')
|
||||
for k, v in six.iteritems(kw):
|
||||
for k, v in kw.items():
|
||||
self.conf.set_override(k, v, group)
|
||||
|
||||
def register_store_schemes(self, store, store_entry):
|
||||
|
|
|
@ -37,7 +37,7 @@ from glance_store.tests.unit import test_store_capabilities
|
|||
|
||||
class FakeObject(object):
|
||||
def __init__(self, **kwargs):
|
||||
for name, value in six.iteritems(kwargs):
|
||||
for name, value in kwargs.items():
|
||||
setattr(self, name, value)
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ def stub_out_swiftclient(stubs, swift_store_auth_version):
|
|||
fixture_containers.append(container)
|
||||
|
||||
def fake_post_container(url, token, container, headers, **kwargs):
|
||||
for key, value in six.iteritems(headers):
|
||||
for key, value in headers.items():
|
||||
fixture_container_headers[key] = value
|
||||
|
||||
def fake_put_object(url, token, container, name, contents, **kwargs):
|
||||
|
@ -151,7 +151,7 @@ def stub_out_swiftclient(stubs, swift_store_auth_version):
|
|||
byte_range = None
|
||||
headers = kwargs.get('headers', dict())
|
||||
if headers is not None:
|
||||
headers = dict((k.lower(), v) for k, v in six.iteritems(headers))
|
||||
headers = dict((k.lower(), v) for k, v in headers.items())
|
||||
if 'range' in headers:
|
||||
byte_range = headers.get('range')
|
||||
|
||||
|
|
Loading…
Reference in New Issue