Reworked the recent change to determine Python files dynamically. eric7 release-10.3.3

Tue, 09 Jul 2024 17:05:43 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 09 Jul 2024 17:05:43 +0200
branch
eric7
changeset 119
6b7a48ea6e66
parent 118
83e88ab0cc38
child 120
a0fc22c59b35

Reworked the recent change to determine Python files dynamically.

ChangeLog file | annotate | diff | comparison | revisions
PluginVulture.py file | annotate | diff | comparison | revisions
PluginVulture.zip file | annotate | diff | comparison | revisions
--- a/ChangeLog	Tue Jul 09 14:36:08 2024 +0200
+++ b/ChangeLog	Tue Jul 09 17:05:43 2024 +0200
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 10.3.3
+- reworked the recent change
+
 Version 10.3.2
 - some code streamlining
 
--- 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"]:
Binary file PluginVulture.zip has changed

eric ide

mercurial