eric6/QScintilla/Editor.py

changeset 7635
0cdead130a81
parent 7628
f904d0eef264
child 7637
c878e8255972
--- a/eric6/QScintilla/Editor.py	Sat Jun 20 17:36:20 2020 +0200
+++ b/eric6/QScintilla/Editor.py	Sun Jun 21 18:26:12 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"
@@ -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 kep 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

eric ide

mercurial