PluginMetricsRadon.py

branch
eric7
changeset 122
bcfe13e956fb
parent 120
61bf877c4f1a
child 124
196b009164dc
--- a/PluginMetricsRadon.py	Tue Jul 09 14:24:30 2024 +0200
+++ b/PluginMetricsRadon.py	Tue Jul 09 16:52:48 2024 +0200
@@ -18,14 +18,14 @@
 from eric7.EricWidgets import EricMessageBox
 from eric7.EricWidgets.EricApplication import ericApp
 from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem
-from eric7.SystemUtilities import FileSystemUtilities
+from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities
 
 # Start-Of-Header
 name = "Radon Metrics Plugin"
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "10.3.1"
+version = "10.3.2"
 className = "RadonMetricsPlugin"
 packageName = "RadonMetrics"
 shortDescription = "Code metrics plugin using radon package"
@@ -248,7 +248,13 @@
         @type str
         """
         if lang is None:
-            lang = "Python3"
+            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("radon_raw", lang, filename, [source])
 
@@ -265,7 +271,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["raw"] = []
         if data["Python3"]:
@@ -295,7 +307,13 @@
         @type str
         """
         if lang is None:
-            lang = "Python3"
+            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("radon_mi", lang, filename, [source])
 
@@ -312,7 +330,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["mi"] = []
         if data["Python3"]:
@@ -342,7 +366,13 @@
         @type str
         """
         if lang is None:
-            lang = "Python3"
+            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("radon_cc", lang, filename, [source])
 
@@ -359,7 +389,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["raw"] = []
         if data["Python3"]:

eric ide

mercurial