diff -r 428c2bec2e8f -r caddf9f36f9f ProjectFlask/Project.py --- a/ProjectFlask/Project.py Wed Dec 02 20:04:05 2020 +0100 +++ b/ProjectFlask/Project.py Sat Dec 05 17:18:17 2020 +0100 @@ -298,6 +298,7 @@ "newForm", self.newForm, self.tr("New template...")) self.__determineCapabilities() + self.__setDebugEnvironment() self.__pybabelProject.projectOpenedHooks() @@ -413,16 +414,18 @@ """ return self.getFullCommand("python") - def getFullCommand(self, command): + def getFullCommand(self, command, virtualEnvPath=None): """ Public method to get the full command for a given command name. @param command command name @type str + @param virtualEnvPath path of the virtual environment + @type str @return full command @rtype str """ - virtualEnv = self.getVirtualEnvironment() + virtualEnv = virtualEnvPath or self.getVirtualEnvironment() if isWindowsPlatform(): fullCmds = [ os.path.join(virtualEnv, "Scripts", command + '.exe'), @@ -720,10 +723,12 @@ from .FlaskConfigDialog import FlaskConfigDialog config = self.getData("flask", "") - dlg = FlaskConfigDialog(config) + dlg = FlaskConfigDialog(config, self) if dlg.exec() == QDialog.Accepted: config = dlg.getConfiguration() self.setData("flask", "", config) + self.__setIgnoreVirtualEnvironment() + self.__setDebugEnvironment() self.__migrateProject.determineCapability() @@ -731,6 +736,38 @@ self.projectClosedHooks() self.projectOpenedHooks() + def __setIgnoreVirtualEnvironment(self): + """ + Private method to add an embedded project specific virtual environment + to the list of ignore files/directories. + """ + virtenvName = self.getData("flask", "virtual_environment_name") + if virtenvName: + virtenvPath = self.getVirtualEnvironment() + if self.__e5project.startswithProjectPath(virtenvPath): + relVirtenvPath = self.__e5project.getRelativeUniversalPath( + virtenvPath) + if relVirtenvPath not in self.__e5project.pdata["FILETYPES"]: + self.__e5project.pdata["FILETYPES"][relVirtenvPath] = ( + "__IGNORE__" + ) + self.__e5project.setDirty(True) + + def __setDebugEnvironment(self): + """ + Private method to set the virtual environment as the selected debug + environment. + """ + language = self.__e5project.getProjectLanguage() + if language == "Python3": + # get project specific virtual environment name + venvName = self.getData("flask", "virtual_environment_name") + if not venvName: + venvName = self.__plugin.getPreferences( + "VirtualEnvironmentNamePy3") + if venvName: + self.__e5project.debugProperties["VIRTUALENV"] = venvName + ################################################################## ## slot below implements documentation function ##################################################################