Collapse normalize_value
function into recursively_normalize_values
This commit is contained in:
parent
ae80647870
commit
3aa0681227
@ -51,12 +51,6 @@ def shouldRecurse(obj, subobject_prop):
|
|||||||
and obj.get('Name') not in ('Deck', 'DeckCustom') \
|
and obj.get('Name') not in ('Deck', 'DeckCustom') \
|
||||||
and len(obj[subobject_prop]) > 1
|
and len(obj[subobject_prop]) > 1
|
||||||
|
|
||||||
def normalize_value(value):
|
|
||||||
rounded = round(value, 2)
|
|
||||||
if rounded == -0.0:
|
|
||||||
return 0.0
|
|
||||||
else:
|
|
||||||
return rounded
|
|
||||||
|
|
||||||
def recursively_normalize_values(d):
|
def recursively_normalize_values(d):
|
||||||
if isinstance(d, dict):
|
if isinstance(d, dict):
|
||||||
@ -64,10 +58,15 @@ def recursively_normalize_values(d):
|
|||||||
elif isinstance(d, list):
|
elif isinstance(d, list):
|
||||||
return [recursively_normalize_values(value) for value in d]
|
return [recursively_normalize_values(value) for value in d]
|
||||||
elif isinstance(d, float):
|
elif isinstance(d, float):
|
||||||
return normalize_value(d)
|
rounded = round(d, 2)
|
||||||
|
if rounded == -0.0:
|
||||||
|
return 0.0
|
||||||
|
else:
|
||||||
|
return rounded
|
||||||
else:
|
else:
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
def recursivelyUnpackObject(parent_dir, obj,
|
def recursivelyUnpackObject(parent_dir, obj,
|
||||||
subobject_prop='ContainedObjects', base_name=None):
|
subobject_prop='ContainedObjects', base_name=None):
|
||||||
def convertObjectsToIncludes(objects):
|
def convertObjectsToIncludes(objects):
|
||||||
|
Loading…
Reference in New Issue
Block a user