AssistantEric/Assistant.py

changeset 177
25cb41783971
parent 174
5c66380af8e3
child 180
89ff060ef0d9
diff -r cd43366c7394 -r 25cb41783971 AssistantEric/Assistant.py
--- a/AssistantEric/Assistant.py	Tue Apr 13 17:39:32 2021 +0200
+++ b/AssistantEric/Assistant.py	Sat Apr 24 10:56:08 2021 +0200
@@ -8,8 +8,6 @@
 calltips system.
 """
 
-from __future__ import unicode_literals
-
 import re
 import imp
 
@@ -118,11 +116,7 @@
         self.__editors.append(editor)
         
         # preload the api to give the manager a chance to prepare the database
-        try:
-            language = editor.getApiLanguage()
-        except AttributeError:
-            # backward compatibility < 16.12
-            language = editor.apiLanguage
+        language = editor.getApiLanguage()
         if language:
             projectType = self.__getProjectType(editor)
             self.__apisManager.getAPIs(language, projectType=projectType)
@@ -158,14 +152,13 @@
         @rtype str
         """
         filename = editor.getFileName()
-        if (
-            self.__project.isOpen() and
-            filename and
-            self.__project.isProjectFile(filename)
-        ):
-            projectType = self.__project.getProjectType()
-        else:
-            projectType = ""
+        projectType = (
+            self.__project.getProjectType()
+            if (self.__project.isOpen() and
+                filename and
+                self.__project.isProjectFile(filename)) else
+            ""
+        )
         
         return projectType
     
@@ -217,12 +210,7 @@
         @param context flag indicating to autocomplete a context (boolean)
         @return list of possible completions (list of strings)
         """
-        try:
-            language = editor.getApiLanguage()
-        except AttributeError:
-            # backward compatibility < 16.12
-            language = editor.apiLanguage
-        
+        language = editor.getApiLanguage()
         completeFromDocumentOnly = False
         if language in ["", "Guessed"] or language.startswith("Pygments|"):
             if (
@@ -284,15 +272,13 @@
         
         prefix = ""
         mod = None
-        if context:
-            beg = beg[:col + 1]
-        else:
-            beg = editor.text(line)[:col]
+        beg = beg[:col + 1] if context else editor.text(line)[:col]
         col = len(beg)
-        if language:
-            wseps = editor.getLexer().autoCompletionWordSeparators()
-        else:
-            wseps = []
+        wseps = (
+            editor.getLexer().autoCompletionWordSeparators()
+            if language else
+            []
+        )
         if wseps:
             wseps.append(" ")
             if col > 0 and beg[col - 1] in wseps:
@@ -718,12 +704,7 @@
             (integer)
         @return list of possible calltips (list of strings)
         """
-        try:
-            language = editor.getApiLanguage()
-        except AttributeError:
-            # backward compatibility < 16.12
-            language = editor.apiLanguage
-        
+        language = editor.getApiLanguage()
         completeFromDocumentOnly = False
         if language in ["", "Guessed"] or language.startswith("Pygments|"):
             if (
@@ -748,10 +729,11 @@
         mod = None
         beg = editor.text(line)[:col]
         col = len(beg)
-        if language:
-            wseps = editor.getLexer().autoCompletionWordSeparators()
-        else:
-            wseps = []
+        wseps = (
+            editor.getLexer().autoCompletionWordSeparators()
+            if language else
+            []
+        )
         if wseps:
             if col > 0 and beg[col - 1] in wseps:
                 col -= 1

eric ide

mercurial