eric6/QScintilla/Editor.py

branch
maintenance
changeset 7642
72721823d453
parent 7607
dd1054be15aa
parent 7637
c878e8255972
child 7684
11e18bf34097
--- a/eric6/QScintilla/Editor.py	Sun May 31 17:26:46 2020 +0200
+++ b/eric6/QScintilla/Editor.py	Sat Jul 04 11:45:34 2020 +0200
@@ -655,8 +655,7 @@
             supportedLanguages = Lexers.getSupportedLanguages()
             if self.filetype in supportedLanguages:
                 bindName = supportedLanguages[self.filetype][1]
-            elif self.filetype in ["Python", "Python2", "Python3",
-                                   "MicroPython"]:
+            elif self.filetype in ["Python", "Python3", "MicroPython"]:
                 bindName = "dummy.py"
         
         if not bindName and line0.startswith("#!"):
@@ -664,21 +663,15 @@
             if "python3" in line0:
                 bindName = "dummy.py"
                 self.filetype = "Python3"
-            elif "python2" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python2"
             elif "python" in line0:
                 bindName = "dummy.py"
-                self.filetype = "Python2"
+                self.filetype = "Python3"
             elif "pypy3" in line0:
                 bindName = "dummy.py"
                 self.filetype = "Python3"
-            elif "pypy2" in line0:
-                bindName = "dummy.py"
-                self.filetype = "Python2"
             elif "pypy" in line0:
                 bindName = "dummy.py"
-                self.filetype = "Python2"
+                self.filetype = "Python3"
             elif ("/bash" in line0 or "/sh" in line0):
                 bindName = "dummy.sh"
             elif "ruby" in line0:
@@ -700,9 +693,6 @@
                 if mode in ["python3", "pypy3"]:
                     bindName = "dummy.py"
                     self.filetype = "Python3"
-                elif mode in ["python2", "pypy2", "python", "pypy"]:
-                    bindName = "dummy.py"
-                    self.filetype = "Python2"
                 elif mode == "ruby":
                     bindName = "dummy.rb"
                     self.filetype = "Ruby"
@@ -1416,7 +1406,7 @@
         @return name of the selected pygments lexer (string)
         """
         from pygments.lexers import get_all_lexers
-        lexerList = sorted(l[0] for l in get_all_lexers())
+        lexerList = sorted(lex[0] for lex in get_all_lexers())
         try:
             lexerSel = lexerList.index(
                 self.getLanguage(normalized=False, forPygments=True))
@@ -1741,7 +1731,7 @@
                 pyVer = Utilities.determinePythonVersion(
                     filename, self.text(0), self)
                 language = "Python{0}".format(pyVer)
-            if language in ['Python2', 'Python3', 'MicroPython', 'Ruby',
+            if language in ['Python3', 'MicroPython', 'Ruby',
                             'JavaScript', 'YAML', 'JSON']:
                 self.filetype = language
             else:
@@ -1843,17 +1833,13 @@
             lang = self.lexer_.name()
             if normalized:
                 # adjust some Pygments lexer names
-                if lang == "Python":
-                    lang = "Python2"
-                elif lang == "Python 3":
+                if lang == "Python 3":
                     lang = "Python3"
         else:
             lang = self.apiLanguage
             if forPygments:
                 # adjust some names to Pygments lexer names
-                if lang == "Python2":
-                    lang = "Python"
-                elif lang == "Python3":
+                if lang == "Python3":
                     lang = "Python 3"
         return lang
     
@@ -2032,10 +2018,10 @@
     
     def __getPyVersion(self):
         """
-        Private method to return the Python main version (2 or 3) or 0 if it's
+        Private method to return the Python main version or 0 if it's
         not a Python file at all.
         
-        @return Python version (2 or 3) or 0 if it's not a Python file (int)
+        @return Python version or 0 if it's not a Python file (int)
         """
         return Utilities.determinePythonVersion(
             self.fileName, self.text(0), self)
@@ -2044,17 +2030,19 @@
         """
         Public method to return a flag indicating a Python (2 or 3) file.
         
-        @return flag indicating a Python (2 or 3) file (boolean)
-        """
-        return self.__getPyVersion() in [2, 3]
+        @return flag indicating a Python3 file (boolean)
+        """
+        return self.__getPyVersion() == 3
     
     def isPy2File(self):
         """
         Public method to return a flag indicating a Python2 file.
         
-        @return flag indicating a Python2 file (boolean)
-        """
-        return self.__getPyVersion() == 2
+        @return flag reporting always False
+        @rtype bool
+        """
+        # kept to keep the API compatible for plugins
+        return False
 
     def isPy3File(self):
         """
@@ -5535,8 +5523,7 @@
                     (coEnable or
                      os.path.isfile("{0}.coverage".format(basename)) or
                      os.path.isfile("{0}.coverage".format(tbasename))) and
-                    (self.project.isPy3Project() or
-                     self.project.isPy2Project())
+                    self.project.isPy3Project()
                 )
         
         # now check ourselves
@@ -6498,8 +6485,6 @@
         @param warningKind kind of warning to clear (Editor.WarningCode,
             Editor.WarningStyle)
         """
-        assert warningKind in [Editor.WarningCode, Editor.WarningStyle]
-        
         for handle in list(self.warnings.keys()):
             warnings = []
             for msg, warningType in self.warnings[handle]:
@@ -8084,12 +8069,12 @@
         formatStr = "@@{0} {1} {2} {3}"
         commands = []
         for token, i1, i2, j1, j2 in matcher.get_opcodes():
-            if token == "insert":
+            if token == "insert":               # secok
                 commands.append(formatStr.format("i", j1, j2 - j1, -1))
                 commands.extend(newL[j1:j2])
-            elif token == "delete":
+            elif token == "delete":             # secok
                 commands.append(formatStr.format("d", j1, i2 - i1, -1))
-            elif token == "replace":
+            elif token == "replace":            # secok
                 commands.append(formatStr.format("r", j1, i2 - i1, j2 - j1))
                 commands.extend(newL[j1:j2])
         

eric ide

mercurial