Fix filter issue for Python 2/3 compatible code.
Change-Id: I5894ed2a2be0ca7fc14004be3059033df7281791 Story: 2003430 Task: 26520 Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
212deb53c0
commit
7816995e87
|
@ -47,7 +47,7 @@ def getcallargs(function, *args, **kwargs):
|
|||
else:
|
||||
keyed_args[argnames[0]] = None
|
||||
|
||||
remaining_argnames = filter(lambda x: x not in keyed_args, argnames)
|
||||
remaining_argnames = [x for x in argnames if x not in keyed_args]
|
||||
keyed_args.update(dict(zip(remaining_argnames, args)))
|
||||
|
||||
if defaults:
|
||||
|
|
|
@ -73,9 +73,9 @@ def generate(srcfiles):
|
|||
os.path.basename(filepath).split('.')[0]])
|
||||
mods_by_pkg.setdefault(pkg_name, list()).append(mod_str)
|
||||
# NOTE(lzyeval): place top level modules before packages
|
||||
pkg_names = filter(lambda x: x.endswith(PY_EXT), mods_by_pkg.keys())
|
||||
pkg_names = [x for x in mods_by_pkg.keys() if x.endswith(PY_EXT)]
|
||||
pkg_names.sort()
|
||||
ext_names = filter(lambda x: x not in pkg_names, mods_by_pkg.keys())
|
||||
ext_names = [x for x in mods_by_pkg.keys() if x not in pkg_names]
|
||||
ext_names.sort()
|
||||
pkg_names.extend(ext_names)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def _dont_use_this():
|
|||
|
||||
|
||||
def _find_objects(t):
|
||||
return filter(lambda o: isinstance(o, t), gc.get_objects())
|
||||
return [o for o in gc.get_objects() if isinstance(o, t)]
|
||||
|
||||
|
||||
def _print_greenthreads():
|
||||
|
|
|
@ -87,8 +87,8 @@ class RedisFanoutExchange(RedisExchange):
|
|||
def run(self, topic):
|
||||
topic = topic.split('~', 1)[1]
|
||||
hosts = self.redis.smembers(topic)
|
||||
good_hosts = filter(
|
||||
lambda host: self.matchmaker.is_alive(topic, host), hosts)
|
||||
good_hosts = [host for host in hosts if
|
||||
self.matchmaker.is_alive(topic, host)]
|
||||
|
||||
return [(x, x.split('.', 1)[1]) for x in good_hosts]
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@ def generate(srcfiles):
|
|||
os.path.basename(filepath).split('.')[0]])
|
||||
mods_by_pkg.setdefault(pkg_name, list()).append(mod_str)
|
||||
# NOTE(lzyeval): place top level modules before packages
|
||||
pkg_names = filter(lambda x: x.endswith(PY_EXT), mods_by_pkg.keys())
|
||||
pkg_names = [x for x in mods_by_pkg.keys() if x.endswith(PY_EXT)]
|
||||
pkg_names.sort()
|
||||
ext_names = filter(lambda x: x not in pkg_names, mods_by_pkg.keys())
|
||||
ext_names = [x for x in mods_by_pkg.keys() if x not in pkg_names]
|
||||
ext_names.sort()
|
||||
pkg_names.extend(ext_names)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def do_service_list(cc, args):
|
|||
fields = ['id', 'name', 'node_name', 'state']
|
||||
field_labels = ['id', 'service_name', 'hostname', 'state']
|
||||
# remove the entry in the initial state
|
||||
clean_list = filter(lambda x: x.state != 'initial', service)
|
||||
clean_list = [x for x in service if x.state != 'initial']
|
||||
for s in clean_list:
|
||||
if s.status:
|
||||
setattr(s, 'state', s.state + '-' + s.status)
|
||||
|
|
Loading…
Reference in New Issue