From 2f396e5897fadc2b9ec8c42d2a4f03665e0cd1df Mon Sep 17 00:00:00 2001 From: l_samenv Date: Thu, 8 Aug 2024 14:00:05 +0200 Subject: [PATCH] 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 --- frappy_psi/sea.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/frappy_psi/sea.py b/frappy_psi/sea.py index f8a8f9e..49c81cb 100644 --- a/frappy_psi/sea.py +++ b/frappy_psi/sea.py @@ -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':