Tue, 23 Jun 2020 17:48:16 +0200
Fixed a few bugs and code style issues.
--- a/ChangeLog Mon Jun 22 19:32:45 2020 +0200 +++ b/ChangeLog Tue Jun 23 17:48:16 2020 +0200 @@ -1,5 +1,8 @@ ChangeLog --------- +Version 6.0.1: +- bug fixes + Version 6.0.0: - removed support for Python2
--- a/PluginDjango.e4p Mon Jun 22 19:32:45 2020 +0200 +++ b/PluginDjango.e4p Tue Jun 23 17:48:16 2020 +0200 @@ -381,7 +381,7 @@ <string>FutureChecker</string> </key> <value> - <string>unicode_literals</string> + <string></string> </value> <key> <string>HangClosing</string>
--- a/PluginProjectDjango.py Mon Jun 22 19:32:45 2020 +0200 +++ b/PluginProjectDjango.py Tue Jun 23 17:48:16 2020 +0200 @@ -26,7 +26,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "6.0.0" +version = "6.0.1" className = "ProjectDjangoPlugin" packageName = "ProjectDjango" shortDescription = "Project support for Django projects."
--- a/ProjectDjango/ConfigurationPage/DjangoPage.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/ConfigurationPage/DjangoPage.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing the Django configuration page. """ -from __future__ import unicode_literals - from PyQt5.QtCore import pyqtSlot from E5Gui import E5FileDialog @@ -87,7 +85,7 @@ venvManager = e5App().getObject("VirtualEnvManager") self.py3VenvNameComboBox.addItems( - [""] + sorted(venvManager.getVirtualenvNamesForVariant(3))) + [""] + sorted(venvManager.getVirtualenvNames())) self.djangoVirtualEnvPy3Group.hide()
--- a/ProjectDjango/DjangoCheckOptionsDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoCheckOptionsDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,12 +7,6 @@ Module implementing a dialog to enter the options for a check operation. """ -from __future__ import unicode_literals -try: - str = unicode # __IGNORE_WARNING__ -except NameError: - pass - import os from PyQt5.QtCore import pyqtSlot, Qt, QProcess
--- a/ProjectDjango/DjangoDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,12 +7,6 @@ Module implementing a dialog starting a process and showing its output. """ -from __future__ import unicode_literals -try: - str = unicode # __IGNORE_WARNING__ -except NameError: - pass - import os from PyQt5.QtCore import pyqtSlot, QProcess, QTimer, QFileInfo
--- a/ProjectDjango/DjangoDiffsettingsDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoDiffsettingsDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data for the 'diffsettings' command. """ -from __future__ import unicode_literals - from PyQt5.QtWidgets import QDialog from .Ui_DjangoDiffsettingsDataDialog import Ui_DjangoDiffsettingsDataDialog
--- a/ProjectDjango/DjangoDumpdataDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoDumpdataDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data for the 'dumpdata' command. """ -from __future__ import unicode_literals - from PyQt5.QtWidgets import QDialog from .Ui_DjangoDumpdataDataDialog import Ui_DjangoDumpdataDataDialog
--- a/ProjectDjango/DjangoLoaddataDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoLoaddataDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data for the 'loaddata' command. """ -from __future__ import unicode_literals - from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog, QDialogButtonBox
--- a/ProjectDjango/DjangoMakeMigrationsDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoMakeMigrationsDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data needed to make migrations. """ -from __future__ import unicode_literals - from PyQt5.QtWidgets import QDialog from .Ui_DjangoMakeMigrationsDialog import Ui_DjangoMakeMigrationsDialog
--- a/ProjectDjango/DjangoMigrationSelectionDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoMigrationSelectionDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to select an application and migration. """ -from __future__ import unicode_literals - import os from PyQt5.QtCore import pyqtSlot
--- a/ProjectDjango/DjangoMigrationsListDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoMigrationsListDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,12 +7,6 @@ Module implementing a dialog show a list of all available migrations. """ -from __future__ import unicode_literals -try: - str = unicode # __IGNORE_WARNING__ -except NameError: - pass - from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QPoint from PyQt5.QtWidgets import ( QDialog, QDialogButtonBox, QAbstractButton,
--- a/ProjectDjango/DjangoRunTestServerDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoRunTestServerDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data for the 'loaddata' command. """ -from __future__ import unicode_literals - from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog, QDialogButtonBox
--- a/ProjectDjango/DjangoSendTestEmailDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoSendTestEmailDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter the data for the 'sendtestemail' command. """ -from __future__ import unicode_literals - from PyQt5.QtWidgets import QDialog from .Ui_DjangoSendTestEmailDataDialog import Ui_DjangoSendTestEmailDataDialog
--- a/ProjectDjango/DjangoSquashMigrationSelectionDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoSquashMigrationSelectionDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter data needed to squash migrations. """ -from __future__ import unicode_literals - import os from PyQt5.QtCore import pyqtSlot
--- a/ProjectDjango/DjangoTestDataDialog.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/DjangoTestDataDialog.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,8 +7,6 @@ Module implementing a dialog to enter some data for running tests. """ -from __future__ import unicode_literals - from PyQt5.QtWidgets import QDialog from .Ui_DjangoTestDataDialog import Ui_DjangoTestDataDialog
--- a/ProjectDjango/Project.py Mon Jun 22 19:32:45 2020 +0200 +++ b/ProjectDjango/Project.py Tue Jun 23 17:48:16 2020 +0200 @@ -7,13 +7,6 @@ Module implementing the Django project support. """ -from __future__ import unicode_literals -try: - str = unicode # __IGNORE_WARNING__ -except NameError: - pass - -import sys import os import re import shutil @@ -117,10 +110,7 @@ self.__ui = parent self.__e5project = e5App().getObject("Project") - try: - self.__virtualEnvManager = e5App().getObject("VirtualEnvManager") - except KeyError: - self.__virtualEnvManager = None + self.__virtualEnvManager = e5App().getObject("VirtualEnvManager") self.__hooksInstalled = False self.__menus = {} # dictionary with references to menus @@ -1280,7 +1270,6 @@ return paths - # TODO: eliminate Python2 def supportedPythonVariants(self): """ Public method to get the supported Python variants. @@ -1317,7 +1306,6 @@ return variants - # TODO: eliminate Python2 def __isSuitableForVariant(self, variant, line0): """ Private method to test, if a detected command file is suitable for the @@ -1347,29 +1335,22 @@ """ if not language: language = self.__e5project.getProjectLanguage() - if self.__virtualEnvManager: - if language == "Python3": - venvName = self.__plugin.getPreferences( - "VirtualEnvironmentNamePy3") - else: - venvName = "" - if venvName: - virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( - venvName) - if not virtEnv: - virtEnv = os.path.dirname( - self.__virtualEnvManager.getVirtualenvInterpreter( - venvName)) - if virtEnv.endswith(("Scripts", "bin")): - virtEnv = os.path.dirname(virtEnv) - else: - virtEnv = "" + if language == "Python3": + venvName = self.__plugin.getPreferences( + "VirtualEnvironmentNamePy3") else: - # backward compatibility - if language == "Python3": - virtEnv = self.__plugin.getPreferences("VirtualEnvironmentPy3") - else: - virtEnv = "" + venvName = "" + if venvName: + virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( + venvName) + if not virtEnv: + virtEnv = os.path.dirname( + self.__virtualEnvManager.getVirtualenvInterpreter( + venvName)) + if virtEnv.endswith(("Scripts", "bin")): + virtEnv = os.path.dirname(virtEnv) + else: + virtEnv = "" if virtEnv and not os.path.exists(virtEnv): virtEnv = "" return virtEnv @@ -1384,33 +1365,18 @@ """ if not language: language = self.__e5project.getProjectLanguage() - if self.__virtualEnvManager: - debugEnv = self.__getVirtualEnvironment(language) - if not debugEnv: - if language == "Python3": - venvName = Preferences.getDebugger("Python3VirtualEnv") - else: - venvName = "" - - if venvName: - debugEnv = self.__virtualEnvManager.getVirtualenvDirectory( - venvName) - else: - debugEnv = "" - else: - # backward compatibility + debugEnv = self.__getVirtualEnvironment(language) + if not debugEnv: if language == "Python3": - debugEnv = Preferences.getDebugger("Python3Interpreter") - if not debugEnv and sys.version_info[0] >= 3: - debugEnv = sys.executable + venvName = Preferences.getDebugger("Python3VirtualEnv") else: - debugEnv = sys.executable - debugEnv = os.path.dirname(debugEnv) - if debugEnv and not os.path.exists(debugEnv): - if language == "Python3" and sys.version_info[0] >= 3: - debugEnv = sys.exec_prefix - else: - debugEnv = "" + venvName = "" + + if venvName: + debugEnv = self.__virtualEnvManager.getVirtualenvDirectory( + venvName) + else: + debugEnv = "" return debugEnv def __getDjangoAdminCommand(self, language=""): @@ -1488,65 +1454,19 @@ @return python command (string) """ language = self.__e5project.getProjectLanguage() - if self.__virtualEnvManager: - if language == "Python3": - venvName = self.__plugin.getPreferences( - "VirtualEnvironmentNamePy3") - if not venvName: - # if none configured, use the global one - venvName = Preferences.getDebugger("Python3VirtualEnv") - else: - venvName = "" - if venvName: - python = self.__virtualEnvManager.getVirtualenvInterpreter( - venvName) - else: - python = "" + if language == "Python3": + venvName = self.__plugin.getPreferences( + "VirtualEnvironmentNamePy3") + if not venvName: + # if none configured, use the global one + venvName = Preferences.getDebugger("Python3VirtualEnv") else: - # backward compatibility - virtualEnv = self.__getVirtualEnvironment() - if isWindowsPlatform(): - pythonExeList = ["python.exe", "pypy.exe"] - if not virtualEnv: - virtualEnv = self.__getDebugEnvironment(language) - for pythonExe in pythonExeList: - for python in [ - os.path.join(virtualEnv, "Scripts", pythonExe), - os.path.join(virtualEnv, "bin", pythonExe), - os.path.join(virtualEnv, pythonExe) - ]: - if os.path.exists(python): - break - else: - python = "" - - if python: - break - else: - python = "" - else: - pythonExeList = ["python3", "pypy3"] - if not virtualEnv: - virtualEnv = self.__getDebugEnvironment(language) - - for pythonExe in pythonExeList: - for python in [ - os.path.join(virtualEnv, "bin", pythonExe), - # omit the version character - os.path.join(virtualEnv, "bin", pythonExe)[:-1], - os.path.join(virtualEnv, pythonExe), - # omit the version character - os.path.join(virtualEnv, pythonExe)[:-1], - ]: - if os.path.exists(python): - break - else: - python = "" - - if python: - break - else: - python = "" + venvName = "" + if venvName: + python = self.__virtualEnvManager.getVirtualenvInterpreter( + venvName) + else: + python = "" return python @@ -2094,23 +2014,12 @@ self.tr('&Current Django project ({0})').format(curSite)) if self.__currentSite is None: - try: - self.__e5project.setTranslationPattern("") - except AttributeError: - # backward compatibility - self.__e5project.pdata["TRANSLATIONPATTERN"] = [] + self.__e5project.setTranslationPattern("") else: - try: - self.__e5project.setTranslationPattern( - os.path.join(site, "locale", "%language%", "LC_MESSAGES", - "django.po") - ) - except AttributeError: - # backward compatibility - self.__e5project.pdata["TRANSLATIONPATTERN"] = [ - os.path.join(site, "locale", "%language%", "LC_MESSAGES", - "django.po") - ] + self.__e5project.setTranslationPattern( + os.path.join(site, "locale", "%language%", "LC_MESSAGES", + "django.po") + ) def __site(self): """