16 from eric7 import Globals, Preferences |
16 from eric7 import Globals, Preferences |
17 from eric7.EricGui.EricAction import EricAction |
17 from eric7.EricGui.EricAction import EricAction |
18 from eric7.EricWidgets import EricMessageBox |
18 from eric7.EricWidgets import EricMessageBox |
19 from eric7.EricWidgets.EricApplication import ericApp |
19 from eric7.EricWidgets.EricApplication import ericApp |
20 from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem |
20 from eric7.Project.ProjectBrowserModel import ProjectBrowserFileItem |
21 from eric7.SystemUtilities import FileSystemUtilities |
21 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities |
22 |
22 |
23 # Start-Of-Header |
23 # Start-Of-Header |
24 name = "Radon Metrics Plugin" |
24 name = "Radon Metrics Plugin" |
25 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
25 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
26 autoactivate = True |
26 autoactivate = True |
27 deactivateable = True |
27 deactivateable = True |
28 version = "10.3.1" |
28 version = "10.3.2" |
29 className = "RadonMetricsPlugin" |
29 className = "RadonMetricsPlugin" |
30 packageName = "RadonMetrics" |
30 packageName = "RadonMetrics" |
31 shortDescription = "Code metrics plugin using radon package" |
31 shortDescription = "Code metrics plugin using radon package" |
32 longDescription = ( |
32 longDescription = ( |
33 """This plug-in implements dialogs to show various code metrics. These""" |
33 """This plug-in implements dialogs to show various code metrics. These""" |
246 @type str |
246 @type str |
247 @param source string containing the code |
247 @param source string containing the code |
248 @type str |
248 @type str |
249 """ |
249 """ |
250 if lang is None: |
250 if lang is None: |
251 lang = "Python3" |
251 try: |
|
252 if PythonUtilities.isPythonSource(filename, source): |
|
253 lang = "Python3" |
|
254 except AttributeError: |
|
255 # backward compatibility for eric-ide < 24.8 |
|
256 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
257 lang = "Python3" |
252 if lang == "Python3": |
258 if lang == "Python3": |
253 self.backgroundService.enqueueRequest("radon_raw", lang, filename, [source]) |
259 self.backgroundService.enqueueRequest("radon_raw", lang, filename, [source]) |
254 |
260 |
255 def rawMetricsBatch(self, argumentsList): |
261 def rawMetricsBatch(self, argumentsList): |
256 """ |
262 """ |
263 """ |
269 """ |
264 data = { |
270 data = { |
265 "Python3": [], |
271 "Python3": [], |
266 } |
272 } |
267 for filename, source in argumentsList: |
273 for filename, source in argumentsList: |
268 data["Python3"].append((filename, source)) |
274 try: |
|
275 if PythonUtilities.isPythonSource(filename, source): |
|
276 data["Python3"].append((filename, source)) |
|
277 except AttributeError: |
|
278 # backward compatibility for eric-ide < 24.8 |
|
279 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
280 data["Python3"].append((filename, source)) |
269 |
281 |
270 self.queuedBatches["raw"] = [] |
282 self.queuedBatches["raw"] = [] |
271 if data["Python3"]: |
283 if data["Python3"]: |
272 self.queuedBatches["raw"].append("Python3") |
284 self.queuedBatches["raw"].append("Python3") |
273 self.backgroundService.enqueueRequest( |
285 self.backgroundService.enqueueRequest( |
293 @type str |
305 @type str |
294 @param source string containing the code |
306 @param source string containing the code |
295 @type str |
307 @type str |
296 """ |
308 """ |
297 if lang is None: |
309 if lang is None: |
298 lang = "Python3" |
310 try: |
|
311 if PythonUtilities.isPythonSource(filename, source): |
|
312 lang = "Python3" |
|
313 except AttributeError: |
|
314 # backward compatibility for eric-ide < 24.8 |
|
315 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
316 lang = "Python3" |
299 if lang == "Python3": |
317 if lang == "Python3": |
300 self.backgroundService.enqueueRequest("radon_mi", lang, filename, [source]) |
318 self.backgroundService.enqueueRequest("radon_mi", lang, filename, [source]) |
301 |
319 |
302 def maintainabilityIndexBatch(self, argumentsList): |
320 def maintainabilityIndexBatch(self, argumentsList): |
303 """ |
321 """ |
310 """ |
328 """ |
311 data = { |
329 data = { |
312 "Python3": [], |
330 "Python3": [], |
313 } |
331 } |
314 for filename, source in argumentsList: |
332 for filename, source in argumentsList: |
315 data["Python3"].append((filename, source)) |
333 try: |
|
334 if PythonUtilities.isPythonSource(filename, source): |
|
335 data["Python3"].append((filename, source)) |
|
336 except AttributeError: |
|
337 # backward compatibility for eric-ide < 24.8 |
|
338 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
339 data["Python3"].append((filename, source)) |
316 |
340 |
317 self.queuedBatches["mi"] = [] |
341 self.queuedBatches["mi"] = [] |
318 if data["Python3"]: |
342 if data["Python3"]: |
319 self.queuedBatches["mi"].append("Python3") |
343 self.queuedBatches["mi"].append("Python3") |
320 self.backgroundService.enqueueRequest( |
344 self.backgroundService.enqueueRequest( |
340 @type str |
364 @type str |
341 @param source string containing the code |
365 @param source string containing the code |
342 @type str |
366 @type str |
343 """ |
367 """ |
344 if lang is None: |
368 if lang is None: |
345 lang = "Python3" |
369 try: |
|
370 if PythonUtilities.isPythonSource(filename, source): |
|
371 lang = "Python3" |
|
372 except AttributeError: |
|
373 # backward compatibility for eric-ide < 24.8 |
|
374 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
375 lang = "Python3" |
346 if lang == "Python3": |
376 if lang == "Python3": |
347 self.backgroundService.enqueueRequest("radon_cc", lang, filename, [source]) |
377 self.backgroundService.enqueueRequest("radon_cc", lang, filename, [source]) |
348 |
378 |
349 def cyclomaticComplexityBatch(self, argumentsList): |
379 def cyclomaticComplexityBatch(self, argumentsList): |
350 """ |
380 """ |
357 """ |
387 """ |
358 data = { |
388 data = { |
359 "Python3": [], |
389 "Python3": [], |
360 } |
390 } |
361 for filename, source in argumentsList: |
391 for filename, source in argumentsList: |
362 data["Python3"].append((filename, source)) |
392 try: |
|
393 if PythonUtilities.isPythonSource(filename, source): |
|
394 data["Python3"].append((filename, source)) |
|
395 except AttributeError: |
|
396 # backward compatibility for eric-ide < 24.8 |
|
397 if PythonUtilities.determinePythonVersion(filename, source) == 3: |
|
398 data["Python3"].append((filename, source)) |
363 |
399 |
364 self.queuedBatches["raw"] = [] |
400 self.queuedBatches["raw"] = [] |
365 if data["Python3"]: |
401 if data["Python3"]: |
366 self.queuedBatches["cc"].append("Python3") |
402 self.queuedBatches["cc"].append("Python3") |
367 self.backgroundService.enqueueRequest( |
403 self.backgroundService.enqueueRequest( |