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 --- install/tools/ipa-csreplica-manage | 3 +-- install/tools/ipa-replica-manage | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'install/tools') diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage index eec8bb2c8..8cf621ec3 100755 --- a/install/tools/ipa-csreplica-manage +++ b/install/tools/ipa-csreplica-manage @@ -23,7 +23,6 @@ import sys import os from ipapython.ipa_log_manager import * - from ipaserver.install import (replication, installutils, bindinstance, cainstance, certs) from ipalib import api, errors @@ -112,7 +111,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose): conn.unbind() if not replica: - for k, p in peers.iteritems(): + for k, p in peers.items(): print '%s: %s' % (k, p[0]) return diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage index f26c6ab60..9688dc4e7 100755 --- a/install/tools/ipa-replica-manage +++ b/install/tools/ipa-replica-manage @@ -183,12 +183,12 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False): peers[ent.single_value['cn']] = config_string.split(':') if not replica: - for k, p in peers.iteritems(): + for k, p in peers.items(): print '%s: %s' % (k, p[0]) return # ok we are being ask for info about a specific replica - for k, p in peers.iteritems(): + for k, p in peers.items(): if replica == k: is_replica = True if p[0] == 'winsync': -- cgit