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: Ib752ad4c3aed525c4bea9dbd5710172ddbaf193b
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 checkpoint action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
@@ -129,7 +127,7 @@ class ShowCheckpoint(command.ShowOne):
|
||||
checkpoint = client.checkpoints.get(parsed_args.provider_id,
|
||||
parsed_args.checkpoint_id)
|
||||
checkpoint._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(checkpoint._info)))
|
||||
return zip(*sorted(checkpoint._info.items()))
|
||||
|
||||
|
||||
class CreateCheckpoint(command.ShowOne):
|
||||
@@ -166,7 +164,7 @@ class CreateCheckpoint(command.ShowOne):
|
||||
parsed_args.plan_id,
|
||||
checkpoint_extra_info)
|
||||
checkpoint._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(checkpoint._info)))
|
||||
return zip(*sorted(checkpoint._info.items()))
|
||||
|
||||
|
||||
class DeleteCheckpoint(command.Command):
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 plan action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
@@ -121,7 +119,7 @@ class ShowPlan(command.ShowOne):
|
||||
plan = osc_utils.find_resource(client.plans, parsed_args.plan)
|
||||
|
||||
plan._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(plan._info)))
|
||||
return zip(*sorted(plan._info.items()))
|
||||
|
||||
|
||||
class CreatePlan(command.ShowOne):
|
||||
@@ -185,7 +183,7 @@ class CreatePlan(command.ShowOne):
|
||||
description=parsed_args.description)
|
||||
|
||||
plan._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(plan._info)))
|
||||
return zip(*sorted(plan._info.items()))
|
||||
|
||||
|
||||
class UpdatePlan(command.ShowOne):
|
||||
@@ -234,7 +232,7 @@ class UpdatePlan(command.ShowOne):
|
||||
"Plan %s not found" % parsed_args.plan_id)
|
||||
else:
|
||||
plan._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(plan._info)))
|
||||
return zip(*sorted(plan._info.items()))
|
||||
|
||||
|
||||
class DeletePlan(command.Command):
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 protectables action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
@@ -63,7 +61,7 @@ class ShowProtectable(command.ShowOne):
|
||||
parsed_args.protectable_type)
|
||||
|
||||
protectable._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(protectable._info)))
|
||||
return zip(*sorted(protectable._info.items()))
|
||||
|
||||
|
||||
class ListProtectableInstances(command.Lister):
|
||||
@@ -176,4 +174,4 @@ class ShowProtectableInstance(command.ShowOne):
|
||||
search_opts=search_opts)
|
||||
|
||||
instance._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(instance._info)))
|
||||
return zip(*sorted(instance._info.items()))
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 provider action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
@@ -98,4 +96,4 @@ class ShowProvider(command.ShowOne):
|
||||
parsed_args.provider)
|
||||
|
||||
provider._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(provider._info)))
|
||||
return zip(*sorted(provider._info.items()))
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 restore action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from osc_lib.command import command
|
||||
@@ -110,7 +108,7 @@ class ShowRestore(command.ShowOne):
|
||||
restore = osc_utils.find_resource(client.restores, parsed_args.restore)
|
||||
|
||||
restore._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(restore._info)))
|
||||
return zip(*sorted(restore._info.items()))
|
||||
|
||||
|
||||
class CreateRestore(command.ShowOne):
|
||||
@@ -194,4 +192,4 @@ class CreateRestore(command.ShowOne):
|
||||
parsed_args.restore_target,
|
||||
restore_parameters, restore_auth)
|
||||
restore._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(restore._info)))
|
||||
return zip(*sorted(restore._info.items()))
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
|
||||
"""Data protection V1 triggers action implementations"""
|
||||
|
||||
import six
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils as osc_utils
|
||||
from oslo_log import log as logging
|
||||
@@ -122,7 +120,7 @@ class ShowTrigger(command.ShowOne):
|
||||
trigger = osc_utils.find_resource(client.triggers, parsed_args.trigger)
|
||||
|
||||
trigger._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(trigger._info)))
|
||||
return zip(*sorted(trigger._info.items()))
|
||||
|
||||
|
||||
class CreateTrigger(command.ShowOne):
|
||||
@@ -153,7 +151,7 @@ class CreateTrigger(command.ShowOne):
|
||||
parsed_args.properties)
|
||||
|
||||
trigger._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(trigger._info)))
|
||||
return zip(*sorted(trigger._info.items()))
|
||||
|
||||
|
||||
class UpdateTrigger(command.ShowOne):
|
||||
@@ -195,7 +193,7 @@ class UpdateTrigger(command.ShowOne):
|
||||
"Trigger %s not found" % parsed_args.trigger_id)
|
||||
else:
|
||||
trigger._info.pop("links", None)
|
||||
return zip(*sorted(six.iteritems(trigger._info)))
|
||||
return zip(*sorted(trigger._info.items()))
|
||||
|
||||
|
||||
class DeleteTrigger(command.Command):
|
||||
|
||||
Reference in New Issue
Block a user