frappy_psi.sea: fix mechanism to avoid ambiguous parameter names
previous intended behaviour: when an ambiguous name appears it is prepended by its parent node name in sea separated with underscore (recursively). however, this was not implemented properly and did not work. new behaviour: when the short name of a parameter is ambigous it is using the full path, joined by underscore
This commit is contained in:
@ -545,6 +545,16 @@ class SeaModule(Module):
|
|||||||
attributes['visibility'] = 2
|
attributes['visibility'] = 2
|
||||||
elif base.count('/') > 1:
|
elif base.count('/') > 1:
|
||||||
attributes['visibility'] = 2
|
attributes['visibility'] = 2
|
||||||
|
# check for ambiguous names. candidates are either the last item
|
||||||
|
# of the path or the full path (underscore separated)
|
||||||
|
simple_names = {k: 1 for k in cls.accessibles}
|
||||||
|
for paramdesc in params:
|
||||||
|
path = paramdesc['path']
|
||||||
|
if path:
|
||||||
|
pathlist = path.split('/')
|
||||||
|
if 'key' not in paramdesc:
|
||||||
|
pname = pathlist[-1]
|
||||||
|
simple_names[pname] = simple_names.get(pname, 0) + 1
|
||||||
for paramdesc in params:
|
for paramdesc in params:
|
||||||
path = paramdesc['path']
|
path = paramdesc['path']
|
||||||
readonly = paramdesc.get('readonly', True)
|
readonly = paramdesc.get('readonly', True)
|
||||||
@ -564,11 +574,11 @@ class SeaModule(Module):
|
|||||||
kwds['group'] = 'more'
|
kwds['group'] = 'more'
|
||||||
else:
|
else:
|
||||||
kwds['group'] = pathlist[-2]
|
kwds['group'] = pathlist[-2]
|
||||||
# flatten path to parameter name
|
# take short name if unique
|
||||||
for i in reversed(range(len(pathlist))):
|
if simple_names[pathlist[-1]] == 1:
|
||||||
key = '_'.join(pathlist[i:])
|
key = pathlist[-1]
|
||||||
if not key in cls.accessibles:
|
else:
|
||||||
break
|
key = '_'.join(pathlist)
|
||||||
if key == 'is_running':
|
if key == 'is_running':
|
||||||
kwds['export'] = False
|
kwds['export'] = False
|
||||||
if key == 'target' and kwds.get('group') == 'more':
|
if key == 'target' and kwds.get('group') == 'more':
|
||||||
|
Reference in New Issue
Block a user