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 /ipalib/plugins/service.py | |
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 'ipalib/plugins/service.py')
-rw-r--r-- | ipalib/plugins/service.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index 6d0299164..d20f52876 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -22,6 +22,7 @@ import base64 import os + from ipalib import api, errors, util from ipalib import Str, Flag, Bytes, StrEnum, Bool from ipalib.plugable import Registry @@ -315,7 +316,7 @@ def check_required_principal(ldap, hostname, service): def update_krbticketflags(ldap, entry_attrs, attrs_list, options, existing): add = remove = 0 - for (name, value) in _ticket_flags_map.iteritems(): + for (name, value) in _ticket_flags_map.items(): if name not in options: continue if options[name]: @@ -356,7 +357,7 @@ def set_kerberos_attrs(entry_attrs, options): all_opt = options.get('all', False) - for (name, value) in _ticket_flags_map.iteritems(): + for (name, value) in _ticket_flags_map.items(): if name in options or all_opt: entry_attrs[name] = bool(ticket_flags & value) |