--- a/eric6/UI/UserInterface.py Tue Sep 24 18:46:24 2019 +0200 +++ b/eric6/UI/UserInterface.py Tue Sep 24 19:08:10 2019 +0200 @@ -12,16 +12,20 @@ import sys import logging -from PyQt5.QtCore import pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, \ - PYQT_VERSION_STR, QDate, QIODevice, qVersion, QProcess, QSize, QUrl, \ - QObject, Qt, QUuid, QThread, QUrlQuery +from PyQt5.QtCore import ( + pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, + QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, + QUrlQuery +) from PyQt5.QtGui import QKeySequence, QDesktopServices -from PyQt5.QtWidgets import QSizePolicy, QWidget, QWhatsThis, QToolBar, \ - QDialog, QSplitter, QApplication, QMenu, QVBoxLayout, QDockWidget, \ - QAction, QLabel +from PyQt5.QtWidgets import ( + QSizePolicy, QWidget, QWhatsThis, QToolBar, QDialog, QSplitter, + QApplication, QMenu, QVBoxLayout, QDockWidget, QAction, QLabel +) from PyQt5.Qsci import QSCINTILLA_VERSION_STR -from PyQt5.QtNetwork import QNetworkProxyFactory, QNetworkAccessManager, \ - QNetworkRequest, QNetworkReply +from PyQt5.QtNetwork import ( + QNetworkProxyFactory, QNetworkAccessManager, QNetworkRequest, QNetworkReply +) from .Info import Version, VersionOnly, BugAddress, Program, FeatureAddress from . import Config @@ -42,8 +46,9 @@ import UI.PixmapCache from E5Network.E5NetworkIcon import E5NetworkIcon -from E5Network.E5NetworkProxyFactory import E5NetworkProxyFactory, \ - proxyAuthenticationRequired +from E5Network.E5NetworkProxyFactory import ( + E5NetworkProxyFactory, proxyAuthenticationRequired +) try: from E5Network.E5SslErrorHandler import E5SslErrorHandler SSL_AVAILABLE = True @@ -657,8 +662,9 @@ self.pluginManager.initPluginToolbars(self.toolbarManager) if Preferences.getPluginManager("StartupCleanup"): splash.showMessage(self.tr("Cleaning Plugins Download Area...")) - from PluginManager.PluginRepositoryDialog import \ + from PluginManager.PluginRepositoryDialog import ( PluginRepositoryDownloadCleanup + ) PluginRepositoryDownloadCleanup(quiet=True) # now read the keyboard shortcuts for all the actions @@ -740,8 +746,8 @@ # Create the view manager depending on the configuration setting logging.debug("Creating Viewmanager...") import ViewManager - self.viewmanager = \ - ViewManager.factory(self, self, debugServer, self.pluginManager) + self.viewmanager = ViewManager.factory( + self, self, debugServer, self.pluginManager) leftWidget = QWidget() layout = QVBoxLayout() layout.setContentsMargins(1, 1, 1, 1) @@ -973,8 +979,8 @@ else: self.__shellParent = self.hToolboxDock from QScintilla.Shell import ShellAssembly - self.shellAssembly = \ - ShellAssembly(debugServer, self.viewmanager, self.project, True) + self.shellAssembly = ShellAssembly( + debugServer, self.viewmanager, self.project, True) self.shell = self.shellAssembly.shell() self.__shellParent.widget().insertItem( 0, self.shellAssembly, UI.PixmapCache.getIcon("shell.png"), @@ -1170,8 +1176,8 @@ else: self.__shellParent = self.bottomSidebar from QScintilla.Shell import ShellAssembly - self.shellAssembly = \ - ShellAssembly(debugServer, self.viewmanager, self.project, True) + self.shellAssembly = ShellAssembly( + debugServer, self.viewmanager, self.project, True) self.shell = self.shellAssembly.shell() self.__shellParent.insertTab(0, self.shellAssembly, UI.PixmapCache.getIcon("shell.png"), @@ -1469,8 +1475,7 @@ @param project project name to be displayed (string) """ if editor is not None and self.captionShowsFilename: - self.capEditor = \ - Utilities.compactPath(editor, self.maxFilePathLen) + self.capEditor = Utilities.compactPath(editor, self.maxFilePathLen) if project is not None: self.capProject = project @@ -2904,8 +2909,10 @@ """ self.__menus = {} mb = self.menuBar() - if Utilities.isLinuxPlatform() and \ - not Preferences.getUI("UseNativeMenuBar"): + if ( + Utilities.isLinuxPlatform() and + not Preferences.getUI("UseNativeMenuBar") + ): mb.setNativeMenuBar(False) ############################################################## @@ -2965,8 +2972,9 @@ ## Project menu ############################################################## - self.__menus["project"], self.__menus["project_tools"] = \ + self.__menus["project"], self.__menus["project_tools"] = ( self.project.initMenus() + ) mb.addMenu(self.__menus["project"]) mb.addMenu(self.__menus["project_tools"]) @@ -2974,8 +2982,9 @@ ## Start and Debug menus ############################################################## - self.__menus["start"], self.__menus["debug"] = \ + self.__menus["start"], self.__menus["debug"] = ( self.debuggerUI.initMenus() + ) mb.addMenu(self.__menus["start"]) mb.addMenu(self.__menus["debug"]) @@ -3158,8 +3167,8 @@ ## Window/Toolbars menu ############################################################## - self.__menus["toolbars"] = \ - QMenu(self.tr("&Toolbars"), self.__menus["window"]) + self.__menus["toolbars"] = QMenu( + self.tr("&Toolbars"), self.__menus["window"]) self.__menus["toolbars"].setTearOffEnabled(True) self.__menus["toolbars"].aboutToShow.connect(self.__showToolbarsMenu) self.__menus["toolbars"].triggered.connect(self.__TBMenuTriggered) @@ -3637,26 +3646,31 @@ versionText = self.tr( """<h3>Version Numbers</h3>""" """<table>""") - versionText += """<tr><td><b>Python</b></td><td>{0}, {1}</td></tr>"""\ - .format(sys.version.split()[0], sizeStr) - versionText += """<tr><td><b>Qt</b></td><td>{0}</td></tr>"""\ - .format(qVersion()) - versionText += """<tr><td><b>PyQt</b></td><td>{0}</td></tr>"""\ - .format(PYQT_VERSION_STR) - versionText += """<tr><td><b>sip</b></td><td>{0}</td></tr>"""\ - .format(sip_version_str) - versionText += """<tr><td><b>QScintilla</b></td><td>{0}</td></tr>"""\ - .format(QSCINTILLA_VERSION_STR) + versionText += ( + """<tr><td><b>Python</b></td><td>{0}, {1}</td></tr>""" + ).format(sys.version.split()[0], sizeStr) + versionText += ( + """<tr><td><b>Qt</b></td><td>{0}</td></tr>""" + ).format(qVersion()) + versionText += ( + """<tr><td><b>PyQt</b></td><td>{0}</td></tr>""" + ).format(PYQT_VERSION_STR) + versionText += ( + """<tr><td><b>sip</b></td><td>{0}</td></tr>""" + ).format(sip_version_str) + versionText += ( + """<tr><td><b>QScintilla</b></td><td>{0}</td></tr>""" + ).format(QSCINTILLA_VERSION_STR) try: from WebBrowser.Tools import WebBrowserTools chromeVersion = WebBrowserTools.getWebEngineVersions()[0] - versionText += \ - """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>"""\ - .format(chromeVersion) + versionText += ( + """<tr><td><b>WebEngine</b></td><td>{0}</td></tr>""" + ).format(chromeVersion) except ImportError: pass - versionText += """<tr><td><b>{0}</b></td><td>{1}</td></tr>"""\ - .format(Program, Version) + versionText += ("""<tr><td><b>{0}</b></td><td>{1}</td></tr>""" + ).format(Program, Version) versionText += self.tr("""</table>""") E5MessageBox.about(self, Program, versionText) @@ -4270,19 +4284,25 @@ self.profiles[self.currentProfile][2][5] = state # step 2: save the visibility of the windows of the active profile if self.__layoutType == "Toolboxes": - self.profiles[self.currentProfile][1][0] = \ + self.profiles[self.currentProfile][1][0] = ( self.lToolboxDock.isVisible() - self.profiles[self.currentProfile][1][1] = \ + ) + self.profiles[self.currentProfile][1][1] = ( self.hToolboxDock.isVisible() - self.profiles[self.currentProfile][1][2] = \ + ) + self.profiles[self.currentProfile][1][2] = ( self.rToolboxDock.isVisible() + ) elif self.__layoutType == "Sidebars": - self.profiles[self.currentProfile][1][0] = \ + self.profiles[self.currentProfile][1][0] = ( self.leftSidebar.isVisible() - self.profiles[self.currentProfile][1][1] = \ + ) + self.profiles[self.currentProfile][1][1] = ( self.bottomSidebar.isVisible() - self.profiles[self.currentProfile][1][2] = \ + ) + self.profiles[self.currentProfile][1][2] = ( self.rightSidebar.isVisible() + ) Preferences.setUI("ViewProfiles2", self.profiles) def __activateViewProfile(self, name, save=True): @@ -4753,8 +4773,9 @@ """ Private slot to handle the tool groups configuration menu entry. """ - from Preferences.ToolGroupConfigurationDialog import \ + from Preferences.ToolGroupConfigurationDialog import ( ToolGroupConfigurationDialog + ) dlg = ToolGroupConfigurationDialog( self.toolGroups, self.currentToolGroup, self) if dlg.exec_() == QDialog.Accepted: @@ -4954,8 +4975,11 @@ if fn is not None: fn = fn.replace('.qm', '.ts') try: - if os.path.isfile(fn) and os.path.getsize(fn) and \ - fn not in args: + if ( + os.path.isfile(fn) and + os.path.getsize(fn) and + fn not in args + ): args.append(fn) else: E5MessageBox.critical( @@ -5150,8 +5174,10 @@ .format(fn)) return - if not os.path.isfile(viewer) or \ - not proc.startDetached(sys.executable, args): + if ( + not os.path.isfile(viewer) or + not proc.startDetached(sys.executable, args) + ): E5MessageBox.critical( self, self.tr('Process Generation Error'), @@ -5205,8 +5231,10 @@ .format(fn)) return - if not os.path.isfile(viewer) or \ - not proc.startDetached(sys.executable, args): + if ( + not os.path.isfile(viewer) or + not proc.startDetached(sys.executable, args) + ): E5MessageBox.critical( self, self.tr('Process Generation Error'), @@ -5226,8 +5254,10 @@ args = [] args.append(browser) - if not os.path.isfile(browser) or \ - not proc.startDetached(sys.executable, args): + if ( + not os.path.isfile(browser) or + not proc.startDetached(sys.executable, args) + ): E5MessageBox.critical( self, self.tr('Process Generation Error'), @@ -5296,8 +5326,10 @@ args = [] args.append(snap) - if not os.path.isfile(snap) or \ - not proc.startDetached(sys.executable, args): + if ( + not os.path.isfile(snap) or + not proc.startDetached(sys.executable, args) + ): E5MessageBox.critical( self, self.tr('Process Generation Error'), @@ -5369,8 +5401,8 @@ args = [] argv = Utilities.parseOptionString(tool['arguments']) args.extend(argv) - t = self.tr("Starting process '{0} {1}'.\n")\ - .format(program, tool['arguments']) + t = self.tr("Starting process '{0} {1}'.\n" + ).format(program, tool['arguments']) self.appendToStdout(t) proc.finished.connect(self.__toolFinished) @@ -5409,8 +5441,10 @@ for program, toolProc, toolProcData in self.toolProcs: toolProc.setReadChannel(QProcess.StandardOutput) - if toolProcData[0] is None or \ - toolProcData[1] not in ["insert", "replaceSelection"]: + if ( + toolProcData[0] is None or + toolProcData[1] not in ["insert", "replaceSelection"] + ): # not connected to an editor or wrong mode while toolProc.canReadLine(): output = str(toolProc.readLine(), ioEncoding, 'replace') @@ -5472,14 +5506,16 @@ if not pythonDocDir: if Utilities.isWindowsPlatform(): venvName = Preferences.getDebugger("Python3VirtualEnv") - interpreter = e5App().getObject("VirtualEnvManager")\ + interpreter = ( + e5App().getObject("VirtualEnvManager") .getVirtualenvInterpreter(venvName) + ) if interpreter: default = os.path.join(os.path.dirname(interpreter), "doc") else: default = "" - pythonDocDir = \ - Utilities.getEnvironmentEntry("PYTHON3DOCDIR", default) + pythonDocDir = Utilities.getEnvironmentEntry( + "PYTHON3DOCDIR", default) else: pythonDocDir = Utilities.getEnvironmentEntry( "PYTHON3DOCDIR", @@ -5540,14 +5576,16 @@ if not pythonDocDir: if Utilities.isWindowsPlatform(): venvName = Preferences.getDebugger("Python2VirtualEnv") - interpreter = e5App().getObject("VirtualEnvManager")\ + interpreter = ( + e5App().getObject("VirtualEnvManager") .getVirtualenvInterpreter(venvName) + ) if interpreter: default = os.path.join(os.path.dirname(interpreter), "doc") else: default = "" - pythonDocDir = \ - Utilities.getEnvironmentEntry("PYTHON2DOCDIR", default) + pythonDocDir = Utilities.getEnvironmentEntry( + "PYTHON2DOCDIR", default) else: pythonDocDir = Utilities.getEnvironmentEntry( "PYTHON2DOCDIR", @@ -5994,8 +6032,9 @@ -1 = server exited with an error code) @rtype int """ - from WebBrowser.WebBrowserSingleApplication import \ + from WebBrowser.WebBrowserSingleApplication import ( WebBrowserSingleApplicationClient + ) webBrowserClient = WebBrowserSingleApplicationClient( self.__webBrowserSAName) @@ -6008,9 +6047,11 @@ connectCount -= 1 QThread.msleep(1000) QApplication.processEvents() - if process.state() == QProcess.NotRunning and \ - process.exitStatus() == QProcess.NormalExit and \ - process.exitCode() == 100: + if ( + process.state() == QProcess.NotRunning and + process.exitStatus() == QProcess.NormalExit and + process.exitCode() == 100 + ): # Process exited prematurely due to missing pre-requisites return -1 if res <= 0: @@ -6098,10 +6139,12 @@ self.__configurationDialog.setPreferences() Preferences.syncPreferences() self.__preferencesChanged() - self.__lastConfigurationPageName = \ + self.__lastConfigurationPageName = ( self.__configurationDialog.getConfigurationPageName() - self.__expandedConfigurationEntries = \ + ) + self.__expandedConfigurationEntries = ( self.__configurationDialog.getExpandedEntries() + ) self.__configurationDialog.deleteLater() self.__configurationDialog = None @@ -6201,8 +6244,9 @@ Preferences.convertPasswords(oldPassword, newPassword) variant = Globals.getWebBrowserSupport() if variant == "QtWebEngine": - from WebBrowser.Passwords.PasswordManager import \ + from WebBrowser.Passwords.PasswordManager import ( PasswordManager + ) pwManager = PasswordManager() pwManager.masterPasswordChanged(oldPassword, newPassword) Utilities.crypto.changeRememberedMaster(newPassword) @@ -6316,8 +6360,9 @@ if dlg.exec_() == QDialog.Accepted: # recent files, recent projects, recent multi projects, # debug histories, shell histories - (files, projects, multiProjects, debug, shell, vcs, plugins) = \ + (files, projects, multiProjects, debug, shell, vcs, plugins) = ( dlg.getData() + ) if files: # clear list of recently opened files self.viewmanager.clearRecent() @@ -6354,8 +6399,8 @@ """ from Debugger.DebugClientCapabilities import HasUnittest self.__setWindowCaption(project=self.project.name) - cap = e5App().getObject("DebugServer")\ - .getClientCapabilities(self.project.getProjectLanguage()) + cap = e5App().getObject("DebugServer").getClientCapabilities( + self.project.getProjectLanguage()) self.utProjectAct.setEnabled(cap & HasUnittest) self.utProjectOpen = cap & HasUnittest @@ -6632,9 +6677,11 @@ """ Private slot to write a crash session file. """ - if not self.__readingSession and \ - not self.__disableCrashSession and \ - Preferences.getUI("CrashSessionEnabled"): + if ( + not self.__readingSession and + not self.__disableCrashSession and + Preferences.getUI("CrashSessionEnabled") + ): self.__writeSession(crashSession=True) def __readCrashSession(self): @@ -6645,9 +6692,11 @@ @rtype bool """ res = False - if not self.__disableCrashSession and \ - not self.__noCrashOpenAtStartup and \ - Preferences.getUI("OpenCrashSessionOnStartup"): + if ( + not self.__disableCrashSession and + not self.__noCrashOpenAtStartup and + Preferences.getUI("OpenCrashSessionOnStartup") + ): fn = os.path.join(Utilities.getConfigDir(), "eric6_crash_session.e5s") if os.path.exists(fn): @@ -6707,8 +6756,8 @@ """ if self.replaceFilesDialog is None: from .FindFileDialog import FindFileDialog - self.replaceFilesDialog = \ - FindFileDialog(self.project, replaceMode=True) + self.replaceFilesDialog = FindFileDialog( + self.project, replaceMode=True) self.replaceFilesDialog.sourceFile.connect( self.viewmanager.openSourceFile) self.replaceFilesDialog.designerFile.connect(self.__designer) @@ -7081,9 +7130,11 @@ ioEncoding = Preferences.getSystem("IOEncoding") versions = str(reply.readAll(), ioEncoding, 'replace').splitlines() reply.close() - if reply.error() != QNetworkReply.NoError or \ - len(versions) == 0 or \ - versions[0].startswith("<"): + if ( + reply.error() != QNetworkReply.NoError or + len(versions) == 0 or + versions[0].startswith("<") + ): # network error or an error page self.httpAlternative += 1 if self.httpAlternative >= len(self.__httpAlternatives): @@ -7247,11 +7298,12 @@ if versions[line] == "---": break - versionText += """<tr><td>{0}</td><td><a href="{1}">{2}</a>""" \ - """</td></tr>""".format( - versions[line], versions[line + 1], - 'sourceforge' in versions[line + 1] and - "SourceForge" or versions[line + 1]) + versionText += ( + """<tr><td>{0}</td><td><a href="{1}">{2}</a></td></tr>""" + ).format( + versions[line], versions[line + 1], + 'sourceforge' in versions[line + 1] and + "SourceForge" or versions[line + 1]) line += 2 versionText += self.tr("""</table>""")