From 1b4865c6086423c0a09b0897e76664fa60e49a7f Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 25 Sep 2020 11:30:23 +0200 Subject: [PATCH] Revert "support name mangling for parameter/command names" This reverts commit 99bdafdd0c3293d17e3f23508d2b7762804474e7. --- secop/client/__init__.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/secop/client/__init__.py b/secop/client/__init__.py index fba9cb1..27d53fd 100644 --- a/secop/client/__init__.py +++ b/secop/client/__init__.py @@ -457,7 +457,8 @@ class SecopClient(ProxyClient): modules = data['modules'] self.modules = {} self.properties = {k: v for k, v in data.items() if k != 'modules'} - self.identifier = defaultdict(dict) # dict of dict of + self.identifier = {} # map (module, parameter) -> identifier + self.internal = {} # map identifier -> (module, parameter) for modname, moddescr in modules.items(): # separate accessibles into command and parameters parameters = {} @@ -468,7 +469,8 @@ class SecopClient(ProxyClient): datatype = get_datatype(aentry['datainfo'], iname) aentry = dict(aentry, datatype=datatype) ident = '%s:%s' % (modname, aname) - self.identifier[modname][iname] = ident + self.identifier[modname, iname] = ident + self.internal[ident] = modname, iname if datatype.IS_COMMAND: commands[iname] = aentry else: @@ -476,11 +478,6 @@ class SecopClient(ProxyClient): properties = {k: v for k, v in moddescr.items() if k != 'accessibles'} self.modules[modname] = dict(accessibles=accessibles, parameters=parameters, commands=commands, properties=properties) - self.fix_internal_names() - # invert self.identifier - self.internal = {ident: (modname, iname) - for modname, identdict in self.identifier.items() - for iname, ident in identdict.items()} if changed_modules is not None: done = done_main = self.callback(None, 'descriptiveDataChange', None, self) for mname in changed_modules: @@ -537,7 +534,7 @@ class SecopClient(ProxyClient): def readParameter(self, module, parameter): """forced read over connection""" try: - self.request(READREQUEST, self.identifier[module][parameter]) + self.request(READREQUEST, self.identifier[module, parameter]) except secop.errors.SECoPError: # error reply message is already stored as readerror in cache pass @@ -556,7 +553,7 @@ class SecopClient(ProxyClient): self.connect() # make sure we are connected datatype = self.modules[module]['parameters'][parameter]['datatype'] value = datatype.export_value(value) - self.request(WRITEREQUEST, self.identifier[module][parameter], value) + self.request(WRITEREQUEST, self.identifier[module, parameter], value) return self.cache[module, parameter] def execCommand(self, module, command, argument=None): @@ -568,7 +565,7 @@ class SecopClient(ProxyClient): if argument is not None: raise secop.errors.BadValueError('command has no argument') # pylint: disable=unsubscriptable-object - data, qualifiers = self.request(COMMANDREQUEST, self.identifier[module][command], argument)[2] + data, qualifiers = self.request(COMMANDREQUEST, self.identifier[module, command], argument)[2] datatype = self.modules[module]['commands'][command]['datatype'].result if datatype: data = datatype.import_value(data) @@ -590,6 +587,3 @@ class SecopClient(ProxyClient): if name.startswith('_') and name[1:] not in self.PREDEFINED_NAMES: return name[1:] return name - - def fix_internal_names(self): - """fix forbidden items"""