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 Co-Authored-By: Akihiro Motoki <amotoki@gmail.com> Change-Id: I4b9edb326444264c0f6c4ad281acaac356a07e85 Implements: blueprint replace-iteritems-with-items
This commit is contained in:
committed by
Akihiro Motoki
parent
4b575083b7
commit
d15bbada73
@@ -23,7 +23,6 @@ import sys
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
import six
|
||||
|
||||
from openstackclient.i18n import _
|
||||
|
||||
@@ -101,7 +100,7 @@ class CreateKeypair(command.ShowOne):
|
||||
del info['public_key']
|
||||
if 'private_key' in info:
|
||||
del info['private_key']
|
||||
return zip(*sorted(six.iteritems(info)))
|
||||
return zip(*sorted(info.items()))
|
||||
else:
|
||||
sys.stdout.write(keypair.private_key)
|
||||
return ({}, {})
|
||||
@@ -184,7 +183,7 @@ class ShowKeypair(command.ShowOne):
|
||||
info.update(keypair._info)
|
||||
if not parsed_args.public_key:
|
||||
del info['public_key']
|
||||
return zip(*sorted(six.iteritems(info)))
|
||||
return zip(*sorted(info.items()))
|
||||
else:
|
||||
# NOTE(dtroyer): a way to get the public key in a similar form
|
||||
# as the private key in the create command
|
||||
|
||||
Reference in New Issue
Block a user