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:
parent
2fee226018
commit
ff83038549
|
@ -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]
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue