diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-08-11 13:51:14 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 11:42:01 +0200 |
commit | 3bf91eab25c602a6fad2665456f57e8629c5a6f4 (patch) | |
tree | 52f713e898a385d57a914d539a7da9a20fc20166 /daemons | |
parent | dd16cc98b0d67f1448bf9de25f8adce512b1431c (diff) | |
download | freeipa-3bf91eab25c602a6fad2665456f57e8629c5a6f4.tar.gz freeipa-3bf91eab25c602a6fad2665456f57e8629c5a6f4.tar.xz freeipa-3bf91eab25c602a6fad2665456f57e8629c5a6f4.zip |
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 <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'daemons')
-rwxr-xr-x | daemons/dnssec/ipa-dnskeysync-replica | 2 | ||||
-rwxr-xr-x | daemons/dnssec/ipa-ods-exporter | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/daemons/dnssec/ipa-dnskeysync-replica b/daemons/dnssec/ipa-dnskeysync-replica index d21626808..77b962414 100755 --- a/daemons/dnssec/ipa-dnskeysync-replica +++ b/daemons/dnssec/ipa-dnskeysync-replica @@ -60,7 +60,7 @@ def update_metadata_set(log, source_set, target_set): def find_unwrapping_key(log, localhsm, wrapping_key_uri): wrap_keys = localhsm.find_keys(uri=wrapping_key_uri) # find usable unwrapping key with matching ID - for key_id, key in wrap_keys.iteritems(): + for key_id, key in wrap_keys.items(): unwrap_keys = localhsm.find_keys(id=key_id, cka_unwrap=True) if len(unwrap_keys) > 0: return unwrap_keys.popitem()[1] diff --git a/daemons/dnssec/ipa-ods-exporter b/daemons/dnssec/ipa-ods-exporter index e7d30014e..0a8287779 100755 --- a/daemons/dnssec/ipa-ods-exporter +++ b/daemons/dnssec/ipa-ods-exporter @@ -96,7 +96,7 @@ def sql2datetimes(row): 'retire': 'idnsSecKeyInactive', 'dead': 'idnsSecKeyDelete'} times = {} - for column, key in row2key_map.iteritems(): + for column, key in row2key_map.items(): if row[column] is not None: times[key] = sql2datetime(row[column]) return times @@ -257,7 +257,7 @@ def master2ldap_master_keys_sync(log, ldapkeydb, localhsm): log.debug('master keys in LDAP after flush: %s', hex_set(ldapkeydb.master_keys)) # synchronize master key metadata to LDAP - for mkey_id, mkey_local in localhsm.master_keys.iteritems(): + for mkey_id, mkey_local in localhsm.master_keys.items(): log.debug('synchronizing master key metadata: 0x%s', hexlify(mkey_id)) sync_pkcs11_metadata(log, mkey_local, ldapkeydb.master_keys[mkey_id]) @@ -265,7 +265,7 @@ def master2ldap_master_keys_sync(log, ldapkeydb, localhsm): enabled_replica_key_ids = set(localhsm.replica_pubkeys_wrap.keys()) log.debug('enabled replica key ids: %s', hex_set(enabled_replica_key_ids)) - for mkey_id, mkey_ldap in ldapkeydb.master_keys.iteritems(): + for mkey_id, mkey_ldap in ldapkeydb.master_keys.items(): log.debug('processing master key data: 0x%s', hexlify(mkey_id)) # check that all active replicas have own copy of master key @@ -273,7 +273,7 @@ def master2ldap_master_keys_sync(log, ldapkeydb, localhsm): for wrapped_entry in mkey_ldap.wrapped_entries: matching_keys = localhsm.find_keys( uri=wrapped_entry.single_value['ipaWrappingKey']) - for matching_key in matching_keys.itervalues(): + for matching_key in matching_keys.values(): assert matching_key['ipk11label'].startswith(u'dnssec-replica:'), \ 'Wrapped key "%s" refers to PKCS#11 URI "%s" which is ' \ 'not a know DNSSEC replica key: label "%s" does not start ' \ |