From d99353c44d540963688976e26bf16f1d12b77a6d Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Tue, 22 Nov 2016 11:25:03 +0700 Subject: 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 --- oslo_i18n/_gettextutils.py | 3 +-- oslo_i18n/_translate.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/oslo_i18n/_gettextutils.py b/oslo_i18n/_gettextutils.py index 75a8313..8d78376 100644 --- a/oslo_i18n/_gettextutils.py +++ b/oslo_i18n/_gettextutils.py @@ -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)) diff --git a/oslo_i18n/_translate.py b/oslo_i18n/_translate.py index 1809e1e..4592196 100644 --- a/oslo_i18n/_translate.py +++ b/oslo_i18n/_translate.py @@ -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) -- cgit v1.2.1