def addDevice(self, deviceName): if deviceName in self.workingFile[DEVICES_GROUP_NAME]: raise KeyError('Device with name \"%s\" already exists.' % deviceName) if not VariableNameValidator.isValidVariableName(deviceName): raise SyntaxError('Device name \"%s\" is not a valid Python variable name.' % deviceName) self.workingFile[DEVICES_GROUP_NAME].create_group(deviceName) self.__buildModelsInFile()
def _tryChangeVariableName(self, currentName, newName): if not currentName or newName == currentName: pass elif newName in self.group: self._warnUser('Duplicate variable name', 'A variable with name \"%s\" already exists for this device.' % newName) elif not VariableNameValidator.isValidVariableName(newName): self._warnUser('Invalid variable name', 'The name \"%s\" is not a valid Python variable name.' % newName) else: currentValue = self.group[currentName] self.group[newName] = currentValue del self.group[currentName] if EMPTY_ROW_STRING in currentName: # Add another new row self._addRow() return True return False
def _validateNewDeviceName(self, deviceName): if deviceName in self.workingFile[DEVICES_GROUP_NAME]: raise KeyError('Device with name \"%s\" already exists.' % deviceName) if not VariableNameValidator.isValidVariableName(deviceName): raise SyntaxError('Device name \"%s\" is not a valid Python variable name.' % deviceName)