Py3: Replace map() with a list comprehension
In Python 3, map() returns a map object, which is not JSON-serializable. Use a list comprehension to fix the issue. Change-Id: I1e50b5057bdca57fcca8a10882e878f63d102ac8
This commit is contained in:
parent
333ae3086f
commit
a883adaa69
@ -31,9 +31,8 @@ def create_bucket_list_json(buckets):
|
|||||||
:param buckets: a list of tuples (or lists) consist of elements orderd as
|
:param buckets: a list of tuples (or lists) consist of elements orderd as
|
||||||
name, count, bytes
|
name, count, bytes
|
||||||
"""
|
"""
|
||||||
bucket_list = map(
|
bucket_list = [{'name': item[0], 'count': item[1], 'bytes': item[2]}
|
||||||
lambda item: {'name': item[0], 'count': item[1], 'bytes': item[2]},
|
for item in buckets]
|
||||||
list(buckets))
|
|
||||||
return json.dumps(bucket_list)
|
return json.dumps(bucket_list)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user