From 3bf91eab25c602a6fad2665456f57e8629c5a6f4 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 11 Aug 2015 13:51:14 +0200 Subject: Use Python3-compatible dict method names Python 2 has keys()/values()/items(), which return lists, iterkeys()/itervalues()/iteritems(), which return iterators, and viewkeys()/viewvalues()/viewitems() which return views. Python 3 has only keys()/values()/items(), which return views. To get iterators, one can use iter() or a for loop/comprehension; for lists there's the list() constructor. When iterating through the entire dict, without modifying the dict, the difference between Python 2's items() and iteritems() is negligible, especially on small dicts (the main overhead is extra memory, not CPU time). In the interest of simpler code, this patch changes many instances of iteritems() to items(), iterkeys() to keys() etc. In other cases, helpers like six.itervalues are used. Reviewed-By: Christian Heimes Reviewed-By: Jan Cholasta --- ipaplatform/redhat/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ipaplatform/redhat/tasks.py') diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py index 5ae2be16f..b211a31ee 100644 --- a/ipaplatform/redhat/tasks.py +++ b/ipaplatform/redhat/tasks.py @@ -361,7 +361,7 @@ class RedHatTaskNamespace(BaseTaskNamespace): def set_selinux_booleans(self, required_settings, backup_func=None): def get_setsebool_args(changes): args = [paths.SETSEBOOL, "-P"] - args.extend(["%s=%s" % update for update in changes.iteritems()]) + args.extend(["%s=%s" % update for update in changes.items()]) return args @@ -370,7 +370,7 @@ class RedHatTaskNamespace(BaseTaskNamespace): updated_vars = {} failed_vars = {} - for setting, state in required_settings.iteritems(): + for setting, state in required_settings.items(): if state is None: continue try: -- cgit