diff -r 8413c2429808 -r 64339135bd61 ProjectDjango/DjangoCheckOptionsDialog.py --- a/ProjectDjango/DjangoCheckOptionsDialog.py Fri Dec 31 13:17:55 2021 +0100 +++ b/ProjectDjango/DjangoCheckOptionsDialog.py Wed Sep 21 16:42:20 2022 +0200 @@ -25,10 +25,11 @@ """ Class implementing a dialog to enter the options for a check operation. """ + def __init__(self, python, path, apps, deployMode, parent=None): """ Constructor - + @param python path of the Python executable @type str @param path site path to run the manage.py script with @@ -42,28 +43,28 @@ """ super().__init__(parent) self.setupUi(self) - + self.settingsFileButton.setIcon(UI.PixmapCache.getIcon("open")) - + self.__python = python self.__path = path - + self.appsComboBox.addItems([""] + apps) - + self.deployCheckBox.setChecked(deployMode) self.on_deployCheckBox_toggled(deployMode) - + @pyqtSlot(bool) def on_deployCheckBox_toggled(self, checked): """ Private slot handling a change of the deploy check box. - + @param checked state of the check box @type bool """ self.settingsFileGroup.setEnabled(checked) self.__populateTagsList(checked) - + @pyqtSlot() def on_settingsFileButton_clicked(self): """ @@ -73,37 +74,31 @@ if not path: path = self.__path settingsFile = EricFileDialog.getOpenFileName( - self, - self.tr("Select settings file"), - path, - self.tr("Python Files (*.py)")) - + self, self.tr("Select settings file"), path, self.tr("Python Files (*.py)") + ) + if settingsFile: self.settingsFileEdit.setText(self.__pathToModule(settingsFile)) - + def __pathToModule(self, path): """ Private method to convert a file path including a .py extension to a module name. - + @param path file path to be converted @type str @return module name @rtype str """ - start = ( - self.__path[:-1] - if self.__path.endswith(("/", "\\")) else - self.__path - ) + start = self.__path[:-1] if self.__path.endswith(("/", "\\")) else self.__path relPath = Utilities.relativeUniversalPath(path, start) mod = os.path.splitext(relPath)[0].replace("/", ".") return mod - + def __moduleToPath(self, moduleName): """ Private method to convert a module name to an file path. - + @param moduleName module name to be converted @type str @return file path @@ -113,16 +108,16 @@ mod = "{0}.py".format(moduleName.replace(".", "/")) if not os.path.isabs(mod): mod = os.path.join(self.__path, mod) - + path = Utilities.toNativeSeparators(mod) else: path = "" return path - + def __populateTagsList(self, deployMode): """ Private slot to populate the tags list. - + @param deployMode flag indicating the deployment mode @type bool """ @@ -130,10 +125,10 @@ selectedTags = [] for itm in self.tagsList.selectedItems(): selectedTags.append(itm.text()) - + # step 2: clear the list self.tagsList.clear() - + # step 3: get the available tags and populate the list args = [] args.append("manage.py") @@ -141,28 +136,30 @@ args.append("--list-tags") if deployMode: args.append("--deploy") - + proc = QProcess() if self.__path: proc.setWorkingDirectory(self.__path) proc.start(self.__python, args) if proc.waitForStarted() and proc.waitForFinished(): - output = str(proc.readAllStandardOutput(), - Preferences.getSystem("IOEncoding"), 'replace') + output = str( + proc.readAllStandardOutput(), + Preferences.getSystem("IOEncoding"), + "replace", + ) for line in output.splitlines(): self.tagsList.addItem(line.strip()) - + # step 4: re-select tags for tag in selectedTags: - items = self.tagsList.findItems( - tag, Qt.MatchFlag.MatchCaseSensitive) + items = self.tagsList.findItems(tag, Qt.MatchFlag.MatchCaseSensitive) if items: items[0].setSelected(True) - + def getData(self): """ Public method to get the options for the check operation. - + @return tuple containing the deployment flag, list of selected tags, applications string and the settings file @rtype tuple of bool, list of str, str and str @@ -170,7 +167,7 @@ selectedTags = [] for itm in self.tagsList.selectedItems(): selectedTags.append(itm.text()) - + return ( self.deployCheckBox.isChecked(), selectedTags,