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:
l_samenv
2024-08-08 14:00:05 +02:00
parent 2c102ad38b
commit 2f396e5897

View File

@ -545,6 +545,16 @@ class SeaModule(Module):
attributes['visibility'] = 2
elif base.count('/') > 1:
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:
path = paramdesc['path']
readonly = paramdesc.get('readonly', True)
@ -564,11 +574,11 @@ class SeaModule(Module):
kwds['group'] = 'more'
else:
kwds['group'] = pathlist[-2]
# flatten path to parameter name
for i in reversed(range(len(pathlist))):
key = '_'.join(pathlist[i:])
if not key in cls.accessibles:
break
# take short name if unique
if simple_names[pathlist[-1]] == 1:
key = pathlist[-1]
else:
key = '_'.join(pathlist)
if key == 'is_running':
kwds['export'] = False
if key == 'target' and kwds.get('group') == 'more':