PluginVulture.py

branch
eric7
changeset 119
6b7a48ea6e66
parent 116
81d24da85ac5
child 121
9b0f92e34a3f
equal deleted inserted replaced
118:83e88ab0cc38 119:6b7a48ea6e66
12 from PyQt6.QtCore import QObject, QTranslator, pyqtSignal 12 from PyQt6.QtCore import QObject, QTranslator, pyqtSignal
13 13
14 from eric7 import Preferences 14 from eric7 import Preferences
15 from eric7.EricGui.EricAction import EricAction 15 from eric7.EricGui.EricAction import EricAction
16 from eric7.EricWidgets.EricApplication import ericApp 16 from eric7.EricWidgets.EricApplication import ericApp
17 from eric7.SystemUtilities import PythonUtilities
17 18
18 # Start-Of-Header 19 # Start-Of-Header
19 name = "Unused Code Checker Plug-in" 20 name = "Unused Code Checker Plug-in"
20 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 21 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
21 autoactivate = True 22 autoactivate = True
22 deactivateable = True 23 deactivateable = True
23 version = "10.3.2" 24 version = "10.3.3"
24 className = "VulturePlugin" 25 className = "VulturePlugin"
25 packageName = "VultureChecker" 26 packageName = "VultureChecker"
26 shortDescription = "Plug-in to detect unused code using the 'vulture' library" 27 shortDescription = "Plug-in to detect unused code using the 'vulture' library"
27 longDescription = """Plug-in to detect unused code using the 'vulture' library.""" 28 longDescription = """Plug-in to detect unused code using the 'vulture' library."""
28 needsRestart = False 29 needsRestart = False
154 @type str 155 @type str
155 @param source string containing the code 156 @param source string containing the code
156 @type str 157 @type str
157 """ 158 """
158 if lang is None: 159 if lang is None:
159 lang = "Python3" 160 try:
160 if lang != "Python3": 161 if PythonUtilities.isPythonSource(filename, source):
161 return 162 lang = "Python3"
162 163 except AttributeError:
163 self.backgroundService.enqueueRequest("vulture", lang, filename, [source]) 164 # backward compatibility for eric-ide < 24.8
165 if PythonUtilities.determinePythonVersion(filename, source) == 3:
166 lang = "Python3"
167 if lang == "Python3":
168 self.backgroundService.enqueueRequest("vulture", lang, filename, [source])
164 169
165 def vultureCheckBatch(self, argumentsList): 170 def vultureCheckBatch(self, argumentsList):
166 """ 171 """
167 Public method to prepare a vulture check for a Python project using 172 Public method to prepare a vulture check for a Python project using
168 the batch mode. 173 the batch mode.
173 """ 178 """
174 data = { 179 data = {
175 "Python3": [], 180 "Python3": [],
176 } 181 }
177 for filename, source in argumentsList: 182 for filename, source in argumentsList:
178 data["Python3"].append((filename, source)) 183 try:
184 if PythonUtilities.isPythonSource(filename, source):
185 data["Python3"].append((filename, source))
186 except AttributeError:
187 # backward compatibility for eric-ide < 24.8
188 if PythonUtilities.determinePythonVersion(filename, source) == 3:
189 data["Python3"].append((filename, source))
179 190
180 self.queuedBatches = [] 191 self.queuedBatches = []
181 if data["Python3"]: 192 if data["Python3"]:
182 self.queuedBatches.append("Python3") 193 self.queuedBatches.append("Python3")
183 self.backgroundService.enqueueRequest( 194 self.backgroundService.enqueueRequest(

eric ide

mercurial