diff options
| author | Petr Viktorin <pviktori@redhat.com> | 2015-08-12 12:25:30 +0200 |
|---|---|---|
| committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 11:42:01 +0200 |
| commit | ace63f4ea55643cb99aaa444d216a6bb9ebb1ed3 (patch) | |
| tree | 0b5367a1b43369dc0ea20b9e8fde91d44abed1f1 /ipalib/plugins | |
| parent | fbacc26a6a8b92f4b3570c411b186ab86cbcc1b1 (diff) | |
| download | freeipa-ace63f4ea55643cb99aaa444d216a6bb9ebb1ed3.tar.gz freeipa-ace63f4ea55643cb99aaa444d216a6bb9ebb1ed3.tar.xz freeipa-ace63f4ea55643cb99aaa444d216a6bb9ebb1ed3.zip | |
Replace uses of map()
In Python 2, map() returns a list; in Python 3 it returns an iterator.
Replace all uses by list comprehensions, generators, or for loops,
as required.
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib/plugins')
| -rw-r--r-- | ipalib/plugins/baseldap.py | 4 | ||||
| -rw-r--r-- | ipalib/plugins/certprofile.py | 2 | ||||
| -rw-r--r-- | ipalib/plugins/dns.py | 2 | ||||
| -rw-r--r-- | ipalib/plugins/host.py | 6 | ||||
| -rw-r--r-- | ipalib/plugins/otptoken.py | 4 | ||||
| -rw-r--r-- | ipalib/plugins/pwpolicy.py | 2 | ||||
| -rw-r--r-- | ipalib/plugins/service.py | 6 | ||||
| -rw-r--r-- | ipalib/plugins/sudorule.py | 11 | ||||
| -rw-r--r-- | ipalib/plugins/trust.py | 6 |
9 files changed, 22 insertions, 21 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 59d39c403..8a375afba 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -300,7 +300,7 @@ def wait_for_value(ldap, dn, attr, value): entry_attrs = ldap.get_entry(dn, ['*']) if attr in entry_attrs: if isinstance(entry_attrs[attr], (list, tuple)): - values = map(lambda y:y.lower(), entry_attrs[attr]) + values = [y.lower() for y in entry_attrs[attr]] if value.lower() in values: break else: @@ -627,7 +627,7 @@ class LDAPObject(Object): ) def has_objectclass(self, classes, objectclass): - oc = map(lambda x:x.lower(),classes) + oc = [x.lower() for x in classes] return objectclass.lower() in oc def convert_attribute_members(self, entry_attrs, *keys, **options): diff --git a/ipalib/plugins/certprofile.py b/ipalib/plugins/certprofile.py index a0ffa3860..8e60a4df8 100644 --- a/ipalib/plugins/certprofile.py +++ b/ipalib/plugins/certprofile.py @@ -292,7 +292,7 @@ class certprofile_del(LDAPDelete): def pre_callback(self, ldap, dn, *keys, **options): ca_enabled_check() - if keys[0] in map(attrgetter('profile_id'), INCLUDED_PROFILES): + if keys[0] in [p.profile_id for p in INCLUDED_PROFILES]: raise errors.ValidationError(name='profile_id', error=_("Predefined profile '%(profile_id)s' cannot be deleted") % {'profile_id': keys[0]} diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 6044d3823..7885f029e 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -3341,7 +3341,7 @@ class dnsrecord(LDAPObject): # during comparison ldap_rrset = dns.rrset.from_text( dns_name, 86400, dns.rdataclass.IN, rdtype, - *map(str, value)) + *[str(v) for v in value]) # make sure that all names are absolute so RRset # comparison will work diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index ec367b8e1..6380962e7 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -643,7 +643,7 @@ class host_add(LDAPCreate): # save the password so it can be displayed in post_callback setattr(context, 'randompassword', entry_attrs['userpassword']) certs = options.get('usercertificate', []) - certs_der = map(x509.normalize_certificate, certs) + certs_der = [x509.normalize_certificate(c) for c in certs] for cert in certs_der: x509.verify_cert_subject(ldap, keys[-1], cert) entry_attrs['usercertificate'] = certs_der @@ -846,7 +846,7 @@ class host_mod(LDAPUpdate): # verify certificates certs = entry_attrs.get('usercertificate') or [] - certs_der = map(x509.normalize_certificate, certs) + certs_der = [x509.normalize_certificate(c) for c in certs] for cert in certs_der: x509.verify_cert_subject(ldap, keys[-1], cert) @@ -857,7 +857,7 @@ class host_mod(LDAPUpdate): except errors.NotFound: self.obj.handle_not_found(*keys) old_certs = entry_attrs_old.get('usercertificate', []) - old_certs_der = map(x509.normalize_certificate, old_certs) + old_certs_der = [x509.normalize_certificate(c) for c in old_certs] removed_certs_der = set(old_certs_der) - set(certs_der) revoke_certs(removed_certs_der, self.log) diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py index 3c2cb9309..57de5b782 100644 --- a/ipalib/plugins/otptoken.py +++ b/ipalib/plugins/otptoken.py @@ -97,8 +97,8 @@ class OTPTokenKey(Bytes): def _convert_owner(userobj, entry_attrs, options): if 'ipatokenowner' in entry_attrs and not options.get('raw', False): - entry_attrs['ipatokenowner'] = map(userobj.get_primary_key_from_dn, - entry_attrs['ipatokenowner']) + entry_attrs['ipatokenowner'] = [userobj.get_primary_key_from_dn(o) + for o in entry_attrs['ipatokenowner']] def _normalize_owner(userobj, entry_attrs): owner = entry_attrs.get('ipatokenowner', None) diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py index 4425a921a..866d57475 100644 --- a/ipalib/plugins/pwpolicy.py +++ b/ipalib/plugins/pwpolicy.py @@ -167,7 +167,7 @@ class cosentry_add(LDAPCreate): except errors.NotFound: self.api.Object.group.handle_not_found(keys[-1]) - oc = map(lambda x:x.lower(),result['objectclass']) + oc = [x.lower() for x in result['objectclass']] if 'mepmanagedentry' in oc: raise errors.ManagedPolicyError() self.obj.check_priority_uniqueness(*keys, **options) diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index d20f52876..39285dd5d 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -541,7 +541,7 @@ class service_add(LDAPCreate): self.obj.validate_ipakrbauthzdata(entry_attrs) certs = options.get('usercertificate', []) - certs_der = map(x509.normalize_certificate, certs) + certs_der = [x509.normalize_certificate(c) for c in certs] for dercert in certs_der: x509.verify_cert_subject(ldap, hostname, dercert) entry_attrs['usercertificate'] = certs_der @@ -617,7 +617,7 @@ class service_mod(LDAPUpdate): # verify certificates certs = entry_attrs.get('usercertificate') or [] - certs_der = map(x509.normalize_certificate, certs) + certs_der = [x509.normalize_certificate(c) for c in certs] for dercert in certs_der: x509.verify_cert_subject(ldap, hostname, dercert) # revoke removed certificates @@ -627,7 +627,7 @@ class service_mod(LDAPUpdate): except errors.NotFound: self.obj.handle_not_found(*keys) old_certs = entry_attrs_old.get('usercertificate', []) - old_certs_der = map(x509.normalize_certificate, old_certs) + old_certs_der = [x509.normalize_certificate(c) for c in old_certs] removed_certs_der = set(old_certs_der) - set(certs_der) revoke_certs(removed_certs_der, self.log) diff --git a/ipalib/plugins/sudorule.py b/ipalib/plugins/sudorule.py index 1bd9042b9..6844343e1 100644 --- a/ipalib/plugins/sudorule.py +++ b/ipalib/plugins/sudorule.py @@ -656,8 +656,8 @@ class sudorule_add_host(LDAPAddMember): if 'hostmask' in options: norm = lambda x: unicode(netaddr.IPNetwork(x).cidr) - old_masks = set(map(norm, _entry_attrs.get('hostmask', []))) - new_masks = set(map(norm, options['hostmask'])) + old_masks = set(norm(m) for m in _entry_attrs.get('hostmask', [])) + new_masks = set(norm(m) for m in options['hostmask']) num_added = len(new_masks - old_masks) @@ -699,10 +699,11 @@ class sudorule_remove_host(LDAPRemoveMember): self.obj.handle_not_found(*keys) if 'hostmask' in options: - norm = lambda x: unicode(netaddr.IPNetwork(x).cidr) + def norm(x): + return unicode(netaddr.IPNetwork(x).cidr) - old_masks = set(map(norm, _entry_attrs.get('hostmask', []))) - removed_masks = set(map(norm, options['hostmask'])) + old_masks = set(norm(m) for m in _entry_attrs.get('hostmask', [])) + removed_masks = set(norm(m) for m in options['hostmask']) num_added = len(removed_masks & old_masks) diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py index 6400a4c54..febe16f1d 100644 --- a/ipalib/plugins/trust.py +++ b/ipalib/plugins/trust.py @@ -534,7 +534,7 @@ class trust(LDAPObject): error=_("invalid SID: %(value)s") % dict(value=value)) def get_dn(self, *keys, **kwargs): - sdn = map(lambda x: ('cn', x), keys) + sdn = [('cn', x) for x in keys] sdn.reverse() trust_type = kwargs.get('trust_type') if trust_type is None: @@ -1233,7 +1233,7 @@ class trust_resolve(Command): if not _nss_idmap_installed: return dict(result=result) try: - sids = map(lambda x: str(x), options['sids']) + sids = [str(x) for x in options['sids']] xlate = pysss_nss_idmap.getnamebysid(sids) for sid in xlate: entry = dict() @@ -1402,7 +1402,7 @@ class trustdomain(LDAPObject): # to the parent object's get_dn() no matter what you pass to it. Make own get_dn() # as we really need all elements to construct proper dn. def get_dn(self, *keys, **kwargs): - sdn = map(lambda x: ('cn', x), keys) + sdn = [('cn', x) for x in keys] sdn.reverse() trust_type = kwargs.get('trust_type') if not trust_type: |
