Replace six.iteritems() with .items()

We should avoid using six.iteritems/keys achieve iterators. We can use
dict.items/keys instead, as it will return iterators in PY3 as well.
And dict.items/keys will more readable.

In py2, the performance about list should be negligible, see
https://wiki.openstack.org/wiki/Python3 and
http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I8cdac1b75918094b9b3acbc65d53d231e86eca19
This commit is contained in:
Luong Anh Tuan 2016-11-22 11:25:03 +07:00 committed by Tuan Luong-Anh
parent b22d9628d0
commit d99353c44d
2 changed files with 2 additions and 3 deletions

View File

@ -22,7 +22,6 @@ import gettext
import os
from babel import localedata
import six
from oslo_i18n import _factory
from oslo_i18n import _locale
@ -82,7 +81,7 @@ def get_available_languages(domain):
'zh_Hant': 'zh_TW',
'fil': 'tl_PH'}
language_list.extend(alias for locale, alias in six.iteritems(aliases)
language_list.extend(alias for locale, alias in aliases.items()
if (locale in language_list and
alias not in language_list))

View File

@ -68,6 +68,6 @@ def translate_args(args, desired_locale=None):
return tuple(translate(v, desired_locale) for v in args)
if isinstance(args, dict):
translated_dict = dict((key, translate(value, desired_locale))
for key, value in six.iteritems(args))
for key, value in args.items())
return translated_dict
return translate(args, desired_locale)