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: I9cf36db9e18d02238ebbfa6962f0ac76d694a43a
This commit is contained in:
parent
fee539e9ad
commit
5d1caeb37f
@ -24,7 +24,6 @@ import copy
|
|||||||
|
|
||||||
from oslo_utils import reflection
|
from oslo_utils import reflection
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from adjutantclient._i18n import _
|
from adjutantclient._i18n import _
|
||||||
@ -293,7 +292,7 @@ class CrudManager(BaseManager):
|
|||||||
|
|
||||||
def _filter_kwargs(self, kwargs):
|
def _filter_kwargs(self, kwargs):
|
||||||
"""Drop null values and handle ids."""
|
"""Drop null values and handle ids."""
|
||||||
for key, ref in six.iteritems(kwargs.copy()):
|
for key, ref in (kwargs.copy().items()):
|
||||||
if ref is None:
|
if ref is None:
|
||||||
kwargs.pop(key)
|
kwargs.pop(key)
|
||||||
else:
|
else:
|
||||||
@ -451,7 +450,7 @@ class Resource(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def _add_details(self, info):
|
def _add_details(self, info):
|
||||||
for (k, v) in six.iteritems(info):
|
for (k, v) in (info).items():
|
||||||
try:
|
try:
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
self._info[k] = v
|
self._info[k] = v
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import six
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
@ -28,7 +27,7 @@ def _show_notification(notification_id, client, formatter):
|
|||||||
if formatter == 'table':
|
if formatter == 'table':
|
||||||
notification._info['notes'] = json.dumps(
|
notification._info['notes'] = json.dumps(
|
||||||
notification.notes, indent=2)
|
notification.notes, indent=2)
|
||||||
return zip(*six.iteritems(notification.to_dict()))
|
return zip(*(notification.to_dict()).items())
|
||||||
|
|
||||||
|
|
||||||
class NotificationList(command.Lister):
|
class NotificationList(command.Lister):
|
||||||
|
@ -13,9 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import six
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ def _show_task(task_id, client, formatter):
|
|||||||
getattr(task, 'action_notes', ""), indent=2)
|
getattr(task, 'action_notes', ""), indent=2)
|
||||||
task._info['approved_by'] = json.dumps(
|
task._info['approved_by'] = json.dumps(
|
||||||
getattr(task, 'approved_by', ""), indent=2)
|
getattr(task, 'approved_by', ""), indent=2)
|
||||||
return zip(*six.iteritems(task.to_dict()))
|
return zip(*(task.to_dict()).items())
|
||||||
|
|
||||||
|
|
||||||
class TaskList(command.Lister):
|
class TaskList(command.Lister):
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
@ -75,7 +74,7 @@ class TokenShow(command.ShowOne):
|
|||||||
else:
|
else:
|
||||||
client = adjutant_client.Client("1", parsed_args.bypass_url)
|
client = adjutant_client.Client("1", parsed_args.bypass_url)
|
||||||
token = client.tokens.get(parsed_args.token)
|
token = client.tokens.get(parsed_args.token)
|
||||||
return zip(*six.iteritems(token.to_dict()))
|
return zip(*(token.to_dict()).items())
|
||||||
|
|
||||||
|
|
||||||
class TokenSubmit(command.Command):
|
class TokenSubmit(command.Command):
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import six
|
|
||||||
|
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
@ -58,7 +57,7 @@ class UserShow(command.ShowOne):
|
|||||||
# be better to do something slightly different here
|
# be better to do something slightly different here
|
||||||
user_id = utils.find_resource(client.users, parsed_args.user)
|
user_id = utils.find_resource(client.users, parsed_args.user)
|
||||||
user = client.users.get(user_id)
|
user = client.users.get(user_id)
|
||||||
return zip(*six.iteritems(user.to_dict()))
|
return zip(*(user.to_dict()).items())
|
||||||
|
|
||||||
|
|
||||||
class UserInvite(command.Command):
|
class UserInvite(command.Command):
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from adjutantclient.common import base
|
from adjutantclient.common import base
|
||||||
@ -75,7 +75,7 @@ class UserManager(base.ManagerWithFind):
|
|||||||
# filters = kwargs.pop('filters')
|
# filters = kwargs.pop('filters')
|
||||||
# params.update(filters)
|
# params.update(filters)
|
||||||
|
|
||||||
for key, value in six.iteritems(kwargs):
|
for key, value in (kwargs).items():
|
||||||
if value:
|
if value:
|
||||||
params[key] = value
|
params[key] = value
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user