Fix using filter() to meet python2,3

As mentioned in link[1], if we need filter on python3,
Replace filter(lambda obj: test(obj), data) with:
[obj for obj in data if test(obj)]. [1]

https://wiki.openstack.org/wiki/Python3

Change-Id: I557bb18519725a9c23cf816d49d717e2e7c1ab59
This commit is contained in:
Ha Van Tu 2016-08-30 11:42:06 +07:00
parent 2fee226018
commit ff83038549
3 changed files with 4 additions and 4 deletions

View File

@ -134,7 +134,7 @@ class Controller(object):
"""
funcs = filter(lambda x: not x.startswith("_"), dir(resource))
funcs = [x for x in dir(resource) if not x.startswith("_")]
if filtered:
funcs = [f for f in funcs if f in filtered]

View File

@ -667,7 +667,7 @@ def _normalize_locations(context, image, force_show_deleted=False):
if force_show_deleted:
locations = image['locations']
else:
locations = filter(lambda x: not x['deleted'], image['locations'])
locations = [x for x in image['locations'] if not x['deleted']]
image['locations'] = [{'id': loc['id'],
'url': loc['url'],
'metadata': loc['metadata'],

View File

@ -199,7 +199,7 @@ def _normalize_locations(context, image, force_show_deleted=False):
if force_show_deleted:
locations = image['locations']
else:
locations = filter(lambda x: not x.deleted, image['locations'])
locations = [x for x in image['locations'] if not x.deleted]
image['locations'] = [{'id': loc['id'],
'url': loc['value'],
'metadata': loc['meta_data'],
@ -209,7 +209,7 @@ def _normalize_locations(context, image, force_show_deleted=False):
def _normalize_tags(image):
undeleted_tags = filter(lambda x: not x.deleted, image['tags'])
undeleted_tags = [x for x in image['tags'] if not x.deleted]
image['tags'] = [tag['value'] for tag in undeleted_tags]
return image