Commit 82c8ee67 authored by Unknown's avatar Unknown
Browse files

Update to unnest_parm_dict

Fixed problem with lists of dictionaries not unnesting properly
parent 892e9b12
......@@ -27,16 +27,28 @@ def unnest_parm_dicts(image_parms, prefix=''):
new_parms = dict()
for name in image_parms.keys():
val = image_parms[name]
# print('name',name,'val',val)
# print('name', name, 'val', val)
name = '-'.join([prefix] + name.split()).strip('-')
if isinstance(val, dict):
new_parms.update(unnest_parm_dicts(val, name))
elif isinstance(val, list):
if len(val) == 0:
elif isinstance(val[0], dict):
for thing in val:
new_parms.update(unnest_parm_dicts(thing, name))
ithing = 0
thing_list = list()
for thing in val:
temp_name = '-'.join([name, str(ithing)])
if isinstance(thing, dict):
thing_dict = unnest_parm_dicts(thing, temp_name)
ithing += 1
if thing_list != list():
new_parms.update({name: thing_list})
new_parms[name] = try_tag_to_string(val)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment