PluginVulture.py

branch
eric7
changeset 119
6b7a48ea6e66
parent 116
81d24da85ac5
child 121
9b0f92e34a3f
--- a/PluginVulture.py	Tue Jul 09 14:36:08 2024 +0200
+++ b/PluginVulture.py	Tue Jul 09 17:05:43 2024 +0200
@@ -14,13 +14,14 @@
 from eric7 import Preferences
 from eric7.EricGui.EricAction import EricAction
 from eric7.EricWidgets.EricApplication import ericApp
+from eric7.SystemUtilities import PythonUtilities
 
 # Start-Of-Header
 name = "Unused Code Checker Plug-in"
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "10.3.2"
+version = "10.3.3"
 className = "VulturePlugin"
 packageName = "VultureChecker"
 shortDescription = "Plug-in to detect unused code using the 'vulture' library"
@@ -156,11 +157,15 @@
         @type str
         """
         if lang is None:
-            lang = "Python3"
-        if lang != "Python3":
-            return
-
-        self.backgroundService.enqueueRequest("vulture", lang, filename, [source])
+            try:
+                if PythonUtilities.isPythonSource(filename, source):
+                    lang = "Python3"
+            except AttributeError:
+                # backward compatibility for eric-ide < 24.8
+                if PythonUtilities.determinePythonVersion(filename, source) == 3:
+                    lang = "Python3"
+        if lang == "Python3":
+            self.backgroundService.enqueueRequest("vulture", lang, filename, [source])
 
     def vultureCheckBatch(self, argumentsList):
         """
@@ -175,7 +180,13 @@
             "Python3": [],
         }
         for filename, source in argumentsList:
-            data["Python3"].append((filename, source))
+            try:
+                if PythonUtilities.isPythonSource(filename, source):
+                    data["Python3"].append((filename, source))
+            except AttributeError:
+                # backward compatibility for eric-ide < 24.8
+                if PythonUtilities.determinePythonVersion(filename, source) == 3:
+                    data["Python3"].append((filename, source))
 
         self.queuedBatches = []
         if data["Python3"]:

eric ide

mercurial