eric6/QScintilla/Shell.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 6989
8b8cadf8d7e9
parent 7267
aedc309827c7
child 7362
028bf21bb5a2
diff -r babe80d84a3e -r 7eb04391adf7 eric6/QScintilla/Shell.py
--- a/eric6/QScintilla/Shell.py	Mon Sep 09 18:52:08 2019 +0200
+++ b/eric6/QScintilla/Shell.py	Thu Oct 03 11:12:10 2019 +0200
@@ -7,7 +7,6 @@
 Module implementing a graphical Python shell.
 """
 
-from __future__ import unicode_literals
 
 import sys
 import re
@@ -19,8 +18,10 @@
 
 from PyQt5.QtCore import pyqtSignal, QFileInfo, Qt, QEvent
 from PyQt5.QtGui import QClipboard, QPalette, QFont
-from PyQt5.QtWidgets import QDialog, QInputDialog, QApplication, QMenu, \
-    QWidget, QHBoxLayout, QVBoxLayout, QShortcut, QSizePolicy
+from PyQt5.QtWidgets import (
+    QDialog, QInputDialog, QApplication, QMenu, QWidget, QHBoxLayout,
+    QVBoxLayout, QShortcut, QSizePolicy
+)
 from PyQt5.Qsci import QsciScintilla
 
 from E5Gui.E5Application import e5App
@@ -30,7 +31,6 @@
 
 import Preferences
 import Utilities
-from Globals import qVersionTuple
 
 import UI.PixmapCache
 
@@ -369,8 +369,9 @@
             QsciScintilla.SCI_CANCEL: self.__QScintillaCancel,
         }
         
-        self.__historyNavigateByCursor = \
+        self.__historyNavigateByCursor = (
             Preferences.getShell("HistoryNavigateByCursor")
+        )
         
         self.__queuedText = ''
         self.__blockTextProcessing = False
@@ -584,8 +585,10 @@
             calltipsStyle = Preferences.getEditor("CallTipsStyle")
             if calltipsStyle == QsciScintilla.CallTipsNoContext:
                 self.setCallTipsStyle(QsciScintilla.CallTipsNoContext)
-            elif calltipsStyle == \
-                    QsciScintilla.CallTipsNoAutoCompletionContext:
+            elif (
+                calltipsStyle ==
+                    QsciScintilla.CallTipsNoAutoCompletionContext
+            ):
                 self.setCallTipsStyle(
                     QsciScintilla.CallTipsNoAutoCompletionContext)
             else:
@@ -633,9 +636,10 @@
             self.__setMargin0()
             self.__setAutoCompletion(self.clientType)
             self.__setCallTips(self.clientType)
-            self.racEnabled = \
-                Preferences.getShell("AutoCompletionEnabled") and \
+            self.racEnabled = (
+                Preferences.getShell("AutoCompletionEnabled") and
                 (cap & HasCompleter) > 0
+            )
             
             if self.clientType not in self.__historyLists:
                 # load history list
@@ -655,8 +659,10 @@
         """
         if index is None:
             # determine based on history style
-            if self.clientType and \
-                    self.__historyStyle == ShellHistoryStyle.WindowsStyle:
+            if (
+                self.clientType and
+                self.__historyStyle == ShellHistoryStyle.WindowsStyle
+            ):
                 idx = int(Preferences.Prefs.settings.value(
                     "Shell/HistoryIndexes/" + self.clientType, -1))
                 if idx >= len(self.__history):
@@ -668,8 +674,10 @@
             self.__histidx = index
             if self.__histidx >= len(self.__history):
                 self.__histidx = -1
-            if self.clientType and \
-                    self.__historyStyle == ShellHistoryStyle.WindowsStyle:
+            if (
+                self.clientType and
+                self.__historyStyle == ShellHistoryStyle.WindowsStyle
+            ):
                 Preferences.Prefs.settings.setValue(
                     "Shell/HistoryIndexes/" + self.clientType, self.__histidx)
     
@@ -871,8 +879,10 @@
         """
         self .__clientError()
         
-        if not self.__windowed and \
-           Preferences.getDebugger("ShowExceptionInShell"):
+        if (
+            not self.__windowed and
+            Preferences.getDebugger("ShowExceptionInShell")
+        ):
             if exceptionType:
                 if stackTrace:
                     self.__write(
@@ -905,8 +915,10 @@
         """
         self .__clientError()
         
-        if not self.__windowed and \
-           Preferences.getDebugger("ShowExceptionInShell"):
+        if (
+            not self.__windowed and
+            Preferences.getDebugger("ShowExceptionInShell")
+        ):
             if message is None:
                 self.__write(self.tr("Unspecified syntax error.\n"))
             else:
@@ -1217,10 +1229,7 @@
         @param evt reference to the wheel event (QWheelEvent)
         """
         if evt.modifiers() & Qt.ControlModifier:
-            if qVersionTuple() >= (5, 0, 0):
-                delta = evt.angleDelta().y()
-            else:
-                delta = evt.delta()
+            delta = evt.angleDelta().y()
             if delta < 0:
                 self.zoomOut()
             elif delta > 0:
@@ -1305,8 +1314,7 @@
                 ac = self.isListActive()
                 super(Shell, self).keyPressEvent(ev)
                 self.incrementalSearchActive = True
-                if ac and \
-                   self.racEnabled:
+                if ac and self.racEnabled:
                     self.dbs.remoteCompletion(self.completionText + txt)
             else:
                 self.__insertTextNoEcho(txt)
@@ -1613,8 +1621,10 @@
             if buf.startswith(sys.ps2):
                 buf = buf.replace(sys.ps2, "")
             if buf and self.incrementalSearchActive:
-                if self.incrementalSearchString and \
-                   buf.startswith(self.incrementalSearchString):
+                if (
+                    self.incrementalSearchString and
+                    buf.startswith(self.incrementalSearchString)
+                ):
                     idx, found = self.__rsearchHistory(
                         self.incrementalSearchString, self.__histidx)
                     if found and idx >= 0:
@@ -1656,8 +1666,10 @@
             if buf.startswith(sys.ps2):
                 buf = buf.replace(sys.ps2, "")
             if buf and self.incrementalSearchActive:
-                if self.incrementalSearchString and \
-                   buf.startswith(self.incrementalSearchString):
+                if (
+                    self.incrementalSearchString and
+                    buf.startswith(self.incrementalSearchString)
+                ):
                     idx, found = self.__searchHistory(
                         self.incrementalSearchString, self.__histidx)
                     if found and idx >= 0:
@@ -1758,8 +1770,10 @@
                     self.__setHistoryIndex(index=-1)
                 elif self.__historyStyle == ShellHistoryStyle.WindowsStyle:
                     if historyIndex is None:
-                        if self.__histidx - 1 > 0 and \
-                           cmd != self.__history[self.__histidx - 1]:
+                        if (
+                            self.__histidx - 1 > 0 and
+                            cmd != self.__history[self.__histidx - 1]
+                        ):
                             self.__setHistoryIndex(index=-1)
                     else:
                         self.__setHistoryIndex(historyIndex)
@@ -1776,8 +1790,9 @@
                                 self.dbs.startClient(
                                     False, forProject=True,
                                     workingDir=self.__project.getProjectPath())
-                                self.__currentWorkingDirectory = \
+                                self.__currentWorkingDirectory = (
                                     self.__project.getProjectPath()
+                                )
                             else:
                                 self.dbs.startClient(
                                     False, venvName=self.__currentVenv,
@@ -1803,8 +1818,10 @@
                 else:
                     cmd = ''
             elif cmd in ['envs', 'environments']:
-                venvs = e5App().getObject("VirtualEnvManager")\
+                venvs = (
+                    e5App().getObject("VirtualEnvManager")
                     .getVirtualenvNames()
+                )
                 s = self.tr('Available Virtual Environments:\n{0}\n').format(
                     '\n'.join("- {0}".format(venv) for venv in sorted(venvs))
                 )
@@ -1817,8 +1834,10 @@
                 self.__write(s)
                 self.__clientStatement(False)
                 return
-            elif cmd in ["quit", "quit()", "exit", "exit()"] and \
-                    self.__windowed:
+            elif (
+                cmd in ["quit", "quit()", "exit", "exit()"] and
+                self.__windowed
+            ):
                 # call main window quit()
                 self.vm.quit()
                 return
@@ -1896,8 +1915,10 @@
             idx = 0
         else:
             idx = startIdx + 1
-        while idx < len(self.__history) and \
-                not self.__history[idx].startswith(txt):
+        while (
+            idx < len(self.__history) and
+            not self.__history[idx].startswith(txt)
+        ):
             idx += 1
         found = (idx < len(self.__history) and
                  self.__history[idx].startswith(txt))
@@ -1919,8 +1940,10 @@
             idx = len(self.__history) - 1
         else:
             idx = startIdx - 1
-        while idx >= 0 and \
-                not self.__history[idx].startswith(txt):
+        while (
+            idx >= 0 and
+            not self.__history[idx].startswith(txt)
+        ):
             idx -= 1
         found = idx >= 0 and self.__history[idx].startswith(txt)
         return idx, found
@@ -1981,8 +2004,9 @@
         venvName = action.text()
         if venvName == self.tr("Project"):
             if self.__project.isOpen():
-                self.__currentWorkingDirectory = \
+                self.__currentWorkingDirectory = (
                     self.__project.getProjectPath()
+                )
             self.dbs.startClient(False, forProject=True,
                                  workingDir=self.__currentWorkingDirectory)
         else:
@@ -2008,15 +2032,16 @@
         # do the history related stuff
         self.__maxHistoryEntries = Preferences.getShell("MaxHistoryEntries")
         for key in list(self.__historyLists.keys()):
-            self.__historyLists[key] = \
+            self.__historyLists[key] = (
                 self.__historyLists[key][-self.__maxHistoryEntries:]
+            )
         self.__historyStyle = Preferences.getShell("HistoryStyle")
         self.__historyWrap = Preferences.getShell("HistoryWrap")
         self.__setHistoryIndex()
         if not self.__windowed:
             self.hmenu.menuAction().setEnabled(self.isHistoryEnabled())
-        self.__historyNavigateByCursor = \
-            Preferences.getShell("HistoryNavigateByCursor")
+        self.__historyNavigateByCursor = Preferences.getShell(
+            "HistoryNavigateByCursor")
         self.historyStyleChanged.emit(self.__historyStyle)
         
         # do stdout /stderr stuff
@@ -2074,8 +2099,10 @@
         
         @param event the drag enter event (QDragEnterEvent)
         """
-        self.inDragDrop = event.mimeData().hasUrls() or \
+        self.inDragDrop = (
+            event.mimeData().hasUrls() or
             event.mimeData().hasText()
+        )
         if self.inDragDrop:
             event.acceptProposedAction()
         else:

eric ide

mercurial