mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
parent
3bf91eab25
commit
5a9141dc40
@ -1128,7 +1128,7 @@ class Object(HasParam):
|
|||||||
self.__get_attrs('Method'), sort=False, name_attr='attr_name'
|
self.__get_attrs('Method'), sort=False, name_attr='attr_name'
|
||||||
)
|
)
|
||||||
self._create_param_namespace('params')
|
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:
|
if len(pkeys) > 1:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'%s (Object) has multiple primary keys: %s' % (
|
'%s (Object) has multiple primary keys: %s' % (
|
||||||
@ -1139,7 +1139,7 @@ class Object(HasParam):
|
|||||||
if len(pkeys) == 1:
|
if len(pkeys) == 1:
|
||||||
self.primary_key = pkeys[0]
|
self.primary_key = pkeys[0]
|
||||||
self.params_minus_pk = NameSpace(
|
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:
|
else:
|
||||||
self.primary_key = None
|
self.primary_key = None
|
||||||
|
@ -792,9 +792,8 @@ class Param(ReadOnly):
|
|||||||
if type(value) not in (tuple, list):
|
if type(value) not in (tuple, list):
|
||||||
value = (value,)
|
value = (value,)
|
||||||
values = tuple(
|
values = tuple(
|
||||||
self._convert_scalar(v, i) for (i, v) in filter(
|
self._convert_scalar(v, i)
|
||||||
lambda iv: not _is_null(iv[1]), enumerate(value)
|
for (i, v) in enumerate(value) if not _is_null(v)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if len(values) == 0:
|
if len(values) == 0:
|
||||||
return
|
return
|
||||||
|
@ -63,7 +63,7 @@ def setup_package():
|
|||||||
description = DOCLINES[0],
|
description = DOCLINES[0],
|
||||||
long_description = "\n".join(DOCLINES[2:]),
|
long_description = "\n".join(DOCLINES[2:]),
|
||||||
download_url = "http://www.freeipa.org/page/Downloads",
|
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': ''},
|
package_dir = {'ipaplatform': ''},
|
||||||
packages = ["ipaplatform",
|
packages = ["ipaplatform",
|
||||||
"ipaplatform.base",
|
"ipaplatform.base",
|
||||||
|
@ -62,7 +62,7 @@ def setup_package():
|
|||||||
description = DOCLINES[0],
|
description = DOCLINES[0],
|
||||||
long_description = "\n".join(DOCLINES[2:]),
|
long_description = "\n".join(DOCLINES[2:]),
|
||||||
download_url = "http://www.freeipa.org/page/Downloads",
|
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"],
|
platforms = ["Linux", "Solaris", "Unix"],
|
||||||
package_dir = {'ipapython': ''},
|
package_dir = {'ipapython': ''},
|
||||||
packages = ["ipapython",
|
packages = ["ipapython",
|
||||||
|
@ -327,7 +327,7 @@ class ADTRUSTInstance(service.Service):
|
|||||||
r.single_value.get('ipaBaseRID'),
|
r.single_value.get('ipaBaseRID'),
|
||||||
r.single_value.get('ipaSecondaryBaseRID')))
|
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
|
# Return if no range is without RID base
|
||||||
if len(ranges_with_no_rid_base) == 0:
|
if len(ranges_with_no_rid_base) == 0:
|
||||||
|
@ -403,7 +403,7 @@ class PSKCKeyPackage(object):
|
|||||||
|
|
||||||
def __dates(self, out, data, key, reducer):
|
def __dates(self, out, data, key, reducer):
|
||||||
dates = (data.get(key + '.sw', None), data.get(key + '.hw', None))
|
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:
|
if dates:
|
||||||
out['ipatoken' + key] = unicode(reducer(dates).strftime("%Y%m%d%H%M%SZ"))
|
out['ipatoken' + key] = unicode(reducer(dates).strftime("%Y%m%d%H%M%SZ"))
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ def setup_package():
|
|||||||
description = DOCLINES[0],
|
description = DOCLINES[0],
|
||||||
long_description = "\n".join(DOCLINES[2:]),
|
long_description = "\n".join(DOCLINES[2:]),
|
||||||
download_url = "http://www.freeipa.org/page/Downloads",
|
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': ''},
|
package_dir = {'ipatests': ''},
|
||||||
packages = ["ipatests",
|
packages = ["ipatests",
|
||||||
"ipatests.pytest_plugins",
|
"ipatests.pytest_plugins",
|
||||||
|
@ -69,7 +69,7 @@ class Config(pytest_multihost.config.Config):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def ad_domains(self):
|
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):
|
def get_all_hosts(self):
|
||||||
for domain in self.domains:
|
for domain in self.domains:
|
||||||
|
Loading…
Reference in New Issue
Block a user