Improved _remove_empty so that it doesn't remove 0, just None

This commit is contained in:
David Sauve
2019-11-06 16:50:52 -08:00
committed by Sébastien Corbin
parent a42a9ca543
commit ea3800375c

View File

@@ -15,8 +15,8 @@ def draw_signature(data, as_file=False):
if `as_file` is True, a temp file is returned instead of Image instance
"""
def _remove_empty_pts(pt):
return {'x': list(filter(None, pt['x'])), 'y': list(filter(None, pt['y']))}
return {'x': list(filter(lambda n: n is not None, pt['x'])), 'y': list(filter(lambda n: n is not None, pt['y']))}
if type(data) is str:
drawing = json.loads(data, object_hook=_remove_empty_pts)
elif type(data) is list: