Commit ac12210e authored by Jerome Mariette's avatar Jerome Mariette
Browse files

better handle of sorted sub parameters

parent 2d171db5
......@@ -312,20 +312,24 @@ class Workflow(threading.Thread):
reader.read(self._get_property_path())
parameters, param_order = [], []
try:
params = {}
params, sub_order = {}, {}
# first grab all parameters name
for param in reader.items(self.parameters_section):
cvalue = reader.get(self.parameters_section, param[0])
cparam = param[0].split(".")[0]
ckey = ".".join(param[0].split(".")[1:])
if len(ckey.split(".")) > 1:
if sub_order.has_key(cparam):
if ckey.split(".")[0] not in sub_order[cparam]: sub_order[cparam].append(ckey.split(".")[0])
else:
sub_order[cparam] =[ckey.split(".")[0]]
if not params.has_key(cparam):
params[cparam] = {ckey: cvalue}
else:
params[cparam][ckey] = cvalue
if cparam not in param_order: param_order.append(cparam)
for param_name in param_order:
sub_params, current_params, sub_objs, sub_order = {}, {}, [], []
sub_params, current_params, sub_objs = {}, {}, []
for param in params[param_name]:
sub_params_values = param.split(".")
if len(sub_params_values) == 2:
......@@ -333,12 +337,12 @@ class Workflow(threading.Thread):
sub_params[sub_params_values[0]] = {sub_params_values[1]: params[param_name][param]}
else:
sub_params[sub_params_values[0]][sub_params_values[1]] = params[param_name][param]
sub_order.append(sub_params_values[0])
else:
current_params[param] = params[param_name][param]
for sub_param in sorted(sub_params.keys()):
sub = Parameter(**sub_params[sub_param])
sub_objs.append(sub)
if sub_order.has_key(param_name):
for sub_param in sub_order[param_name]:
sub = Parameter(**sub_params[sub_param])
sub_objs.append(sub)
current_params["sub_parameters"] = sub_objs
oparam = Parameter(**current_params)
parameters.append(oparam)
......
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