--- a/Debugger/DebugServer.py Sat Aug 26 17:10:43 2017 +0200 +++ b/Debugger/DebugServer.py Sat Aug 26 19:26:07 2017 +0200 @@ -30,11 +30,8 @@ import Utilities -# TODO: change this to a list of debugger interfaces and unite the two Python -# variants because they are nearly identical DebuggerInterfaces = { - "Python2": "DebuggerInterfacePython2", - "Python3": "DebuggerInterfacePython3", + "Python": "DebuggerInterfacePython", "None": "DebuggerInterfaceNone", } @@ -165,12 +162,15 @@ """ super(DebugServer, self).__init__() + self.__debuggerInterfaces = {} + # the interface name is the key, a function to get the + # registration data is the value self.__debuggerInterfaceRegistry = {} # the client language is the key, a list containing the client - # capabilities, the list of associated file extensions, a + # capabilities, a list of associated file extensions, a # function reference to create the debugger interface (see - # __createDebuggerInterface() below) and a function to be called - # to get the registration data as values + # __createDebuggerInterface() below) and the interface name is + # the value # create our models self.breakpointModel = BreakPointModel(self) @@ -294,23 +294,21 @@ """ Public slot to handle the preferencesChanged signal. """ - # TODO: just build a set of registry data functions and call - # registerDebuggerInterface with each of them registeredInterfaces = {} - for language in self.__debuggerInterfaceRegistry: - registeredInterfaces[language] = \ - self.__debuggerInterfaceRegistry[language][-1] - # last entry is the registry data function + for interfaceName in self.__debuggerInterfaces: + registeredInterfaces[interfaceName] = \ + self.__debuggerInterfaces[interfaceName] + self.__debuggerInterfaces = {} self.__debuggerInterfaceRegistry = {} - for language, getRegistryData in registeredInterfaces.items(): - self.registerDebuggerInterface(language, getRegistryData) + for interfaceName, getRegistryData in registeredInterfaces.items(): + self.registerDebuggerInterface(interfaceName, getRegistryData) - def registerDebuggerInterface(self, name, getRegistryData): + def registerDebuggerInterface(self, interfaceName, getRegistryData): """ Public method to register a debugger interface. - @param name name of the debugger interface + @param interfaceName name of the debugger interface @type str @param getRegistryData reference to a function to be called to get the debugger interface details. This method shall @@ -319,9 +317,7 @@ to create the debugger interface (see __createDebuggerInterface()) @type function """ - # TODO: remove the 'name' parameter and move the check below against - # clientLanguage - if name in self.__debuggerInterfaceRegistry: + if interfaceName in self.__debuggerInterfaces: E5MessageBox.warning( None, self.tr("Register Debugger Interface"), @@ -329,24 +325,31 @@ """ been registered. Ignoring this request.</p>""")) return - # TODO: change getRegistryData to return a list of registry entries - clientLanguage, clientCapabilities, clientExtensions, \ - interfaceCreator = getRegistryData() - if clientLanguage: - self.__debuggerInterfaceRegistry[clientLanguage] = \ - [clientCapabilities, clientExtensions, interfaceCreator, - getRegistryData] + registryDataList = getRegistryData() + if registryDataList: + self.__debuggerInterfaces[interfaceName] = getRegistryData + for clientLanguage, clientCapabilities, clientExtensions, \ + interfaceCreator in registryDataList: + self.__debuggerInterfaceRegistry[clientLanguage] = [ + clientCapabilities, clientExtensions, interfaceCreator, + interfaceName] - def unregisterDebuggerInterface(self, name): + def unregisterDebuggerInterface(self, interfaceName): """ Public method to unregister a debugger interface. - @param name name of the debugger interface + @param interfaceName interfaceName of the debugger interface @type str """ - # TODO: change name to a list of names - if name in self.__debuggerInterfaceRegistry: - del self.__debuggerInterfaceRegistry[name] + if interfaceName in self.__debuggerInterfaces: + clientLanguages = [] + for clientLanguage, registryData in \ + self.__debuggerInterfaceRegistry.items(): + if interfaceName == registryData[-1]: + clientLanguages.append(clientLanguage) + for clientLanguage in clientLanguages: + del self.__debuggerInterfaceRegistry[clientLanguage] + del self.__debuggerInterfaces[interfaceName] def __findLanguageForExtension(self, ext): """ @@ -367,7 +370,6 @@ """ Private method to register the available internal debugger interfaces. """ - # TODO: apply DebuggerInterfaces being a list for name, interface in DebuggerInterfaces.items(): modName = "Debugger.{0}".format(interface) mod = __import__(modName) @@ -375,7 +377,6 @@ for comp in components[1:]: mod = getattr(mod, comp) - # TODO: remove name parameter self.registerDebuggerInterface(name, mod.getRegistryData) def getSupportedLanguages(self, shellOnly=False):