diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-08-11 16:42:28 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 11:42:01 +0200 |
commit | 5a9141dc409a4efe5a19d654319529d7c98a667a (patch) | |
tree | 9d386dca310df7af63b7d65e42b5e4d6a6188e8f | |
parent | 3bf91eab25c602a6fad2665456f57e8629c5a6f4 (diff) | |
download | freeipa-5a9141dc409a4efe5a19d654319529d7c98a667a.tar.gz freeipa-5a9141dc409a4efe5a19d654319529d7c98a667a.tar.xz freeipa-5a9141dc409a4efe5a19d654319529d7c98a667a.zip |
Replace filter() calls with list comprehensions
In Python 3, filter() returns an iterator.
Use list comprehensions instead.
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
-rw-r--r-- | ipalib/frontend.py | 4 | ||||
-rw-r--r-- | ipalib/parameters.py | 5 | ||||
-rw-r--r-- | ipaplatform/setup.py.in | 2 | ||||
-rw-r--r-- | ipapython/setup.py.in | 2 | ||||
-rw-r--r-- | ipaserver/install/adtrustinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/ipa_otptoken_import.py | 2 | ||||
-rw-r--r-- | ipatests/setup.py.in | 2 | ||||
-rw-r--r-- | ipatests/test_integration/config.py | 2 |
8 files changed, 10 insertions, 11 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 8cc0dd7b2..d61df02ba 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -1128,7 +1128,7 @@ class Object(HasParam): self.__get_attrs('Method'), sort=False, name_attr='attr_name' ) self._create_param_namespace('params') - pkeys = filter(lambda p: p.primary_key, self.params()) + pkeys = [p for p in self.params() if p.primary_key] if len(pkeys) > 1: raise ValueError( '%s (Object) has multiple primary keys: %s' % ( @@ -1139,7 +1139,7 @@ class Object(HasParam): if len(pkeys) == 1: self.primary_key = pkeys[0] self.params_minus_pk = NameSpace( - filter(lambda p: not p.primary_key, self.params()), sort=False + [p for p in self.params() if not p.primary_key], sort=False ) else: self.primary_key = None diff --git a/ipalib/parameters.py b/ipalib/parameters.py index c9baf414a..175adefb8 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -792,9 +792,8 @@ class Param(ReadOnly): if type(value) not in (tuple, list): value = (value,) values = tuple( - self._convert_scalar(v, i) for (i, v) in filter( - lambda iv: not _is_null(iv[1]), enumerate(value) - ) + self._convert_scalar(v, i) + for (i, v) in enumerate(value) if not _is_null(v) ) if len(values) == 0: return diff --git a/ipaplatform/setup.py.in b/ipaplatform/setup.py.in index 944e68699..08f6c30dd 100644 --- a/ipaplatform/setup.py.in +++ b/ipaplatform/setup.py.in @@ -63,7 +63,7 @@ def setup_package(): description = DOCLINES[0], long_description = "\n".join(DOCLINES[2:]), download_url = "http://www.freeipa.org/page/Downloads", - classifiers=filter(None, CLASSIFIERS.split('\n')), + classifiers=[line for line in CLASSIFIERS.split('\n') if line], package_dir = {'ipaplatform': ''}, packages = ["ipaplatform", "ipaplatform.base", diff --git a/ipapython/setup.py.in b/ipapython/setup.py.in index 6cba59cfc..882142e4b 100644 --- a/ipapython/setup.py.in +++ b/ipapython/setup.py.in @@ -62,7 +62,7 @@ def setup_package(): description = DOCLINES[0], long_description = "\n".join(DOCLINES[2:]), download_url = "http://www.freeipa.org/page/Downloads", - classifiers=filter(None, CLASSIFIERS.split('\n')), + classifiers=[line for line in CLASSIFIERS.split('\n') if line], platforms = ["Linux", "Solaris", "Unix"], package_dir = {'ipapython': ''}, packages = ["ipapython", diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py index 701a605be..1f39dc732 100644 --- a/ipaserver/install/adtrustinstance.py +++ b/ipaserver/install/adtrustinstance.py @@ -327,7 +327,7 @@ class ADTRUSTInstance(service.Service): r.single_value.get('ipaBaseRID'), r.single_value.get('ipaSecondaryBaseRID'))) - ranges_with_no_rid_base = filter(no_rid_base_set, ranges) + ranges_with_no_rid_base = [r for r in ranges if no_rid_base_set(r)] # Return if no range is without RID base if len(ranges_with_no_rid_base) == 0: diff --git a/ipaserver/install/ipa_otptoken_import.py b/ipaserver/install/ipa_otptoken_import.py index ae89f7e07..5f5d21560 100644 --- a/ipaserver/install/ipa_otptoken_import.py +++ b/ipaserver/install/ipa_otptoken_import.py @@ -403,7 +403,7 @@ class PSKCKeyPackage(object): def __dates(self, out, data, key, reducer): dates = (data.get(key + '.sw', None), data.get(key + '.hw', None)) - dates = filter(lambda x: x is not None, dates) + dates = [x for x in dates if x is not None] if dates: out['ipatoken' + key] = unicode(reducer(dates).strftime("%Y%m%d%H%M%SZ")) diff --git a/ipatests/setup.py.in b/ipatests/setup.py.in index 658a330d8..90390c06d 100644 --- a/ipatests/setup.py.in +++ b/ipatests/setup.py.in @@ -63,7 +63,7 @@ def setup_package(): description = DOCLINES[0], long_description = "\n".join(DOCLINES[2:]), download_url = "http://www.freeipa.org/page/Downloads", - classifiers=filter(None, CLASSIFIERS.split('\n')), + classifiers=[line for line in CLASSIFIERS.split('\n') if line], package_dir = {'ipatests': ''}, packages = ["ipatests", "ipatests.pytest_plugins", diff --git a/ipatests/test_integration/config.py b/ipatests/test_integration/config.py index aaee72652..785a9bb8c 100644 --- a/ipatests/test_integration/config.py +++ b/ipatests/test_integration/config.py @@ -69,7 +69,7 @@ class Config(pytest_multihost.config.Config): @property def ad_domains(self): - return filter(lambda d: d.type == 'AD', self.domains) + return [d for d in self.domains if d.type == 'AD'] def get_all_hosts(self): for domain in self.domains: |