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: If5ab2f298e887a90cd43530e3fccc0294412f5c9
This commit is contained in:
parent
8eebf74bfb
commit
1213ccb00f
@ -12,7 +12,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
|
||||
from openstack.object_store import object_store_service
|
||||
from openstack.object_store.v1 import _base
|
||||
@ -168,7 +167,7 @@ class Object(_base.BaseResource):
|
||||
# Filter out items with empty values so the create metadata behaviour
|
||||
# is the same as account and container
|
||||
filtered_metadata = \
|
||||
{key: value for key, value in six.iteritems(metadata) if value}
|
||||
{key: value for key, value in metadata.items() if value}
|
||||
|
||||
# Get a copy of the original metadata so it doesn't get erased on POST
|
||||
# and update it with the new metadata values.
|
||||
|
@ -53,7 +53,6 @@ The resulting preference print out would look something like::
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import six
|
||||
|
||||
from openstack.bare_metal import bare_metal_service
|
||||
from openstack.block_store import block_store_service
|
||||
@ -166,7 +165,7 @@ class Profile(object):
|
||||
def get_services(self):
|
||||
"""Get a list of all the known services."""
|
||||
services = []
|
||||
for name, service in six.iteritems(self._services):
|
||||
for name, service in self._services.items():
|
||||
services.append(service)
|
||||
return services
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from openstack import resource2 as resource
|
||||
from openstack.telemetry import telemetry_service
|
||||
@ -34,5 +33,5 @@ class Capability(resource.Resource):
|
||||
resp = session.get(cls.base_path, endpoint_filter=cls.service,
|
||||
params=params)
|
||||
resp = resp.json()
|
||||
for key, value in six.iteritems(resp['api']):
|
||||
for key, value in resp['api'].items():
|
||||
yield cls.existing(id=key, enabled=value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user