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 |
22 |
22 |
23 try: |
|
24 from eric7.SystemUtilities.PythonUtilities import determinePythonVersion |
|
25 except ImportError: |
|
26 # imports for eric < 23.1 |
|
27 from eric7.Utilities import determinePythonVersion |
|
28 |
|
29 # Start-Of-Header |
23 # Start-Of-Header |
30 name = "Radon Metrics Plugin" |
24 name = "Radon Metrics Plugin" |
31 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
25 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
32 autoactivate = True |
26 autoactivate = True |
33 deactivateable = True |
27 deactivateable = True |
34 version = "10.3.0" |
28 version = "10.3.1" |
35 className = "RadonMetricsPlugin" |
29 className = "RadonMetricsPlugin" |
36 packageName = "RadonMetrics" |
30 packageName = "RadonMetrics" |
37 shortDescription = "Code metrics plugin using radon package" |
31 shortDescription = "Code metrics plugin using radon package" |
38 longDescription = ( |
32 longDescription = ( |
39 """This plug-in implements dialogs to show various code metrics. These""" |
33 """This plug-in implements dialogs to show various code metrics. These""" |
251 @type str |
245 @type str |
252 @param source string containing the code |
246 @param source string containing the code |
253 @type str |
247 @type str |
254 """ |
248 """ |
255 if lang is None: |
249 if lang is None: |
256 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
250 lang = "Python3" |
257 if lang == "Python3": |
251 if lang == "Python3": |
258 self.backgroundService.enqueueRequest("radon_raw", lang, filename, [source]) |
252 self.backgroundService.enqueueRequest("radon_raw", lang, filename, [source]) |
259 |
253 |
260 def rawMetricsBatch(self, argumentsList): |
254 def rawMetricsBatch(self, argumentsList): |
261 """ |
255 """ |
268 """ |
262 """ |
269 data = { |
263 data = { |
270 "Python3": [], |
264 "Python3": [], |
271 } |
265 } |
272 for filename, source in argumentsList: |
266 for filename, source in argumentsList: |
273 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
267 data["Python3"].append((filename, source)) |
274 if lang == "Python3": |
|
275 data[lang].append((filename, source)) |
|
276 |
268 |
277 self.queuedBatches["raw"] = [] |
269 self.queuedBatches["raw"] = [] |
278 if data[lang]: |
270 if data["Python3"]: |
279 self.queuedBatches["raw"].append("Python3") |
271 self.queuedBatches["raw"].append("Python3") |
280 self.backgroundService.enqueueRequest( |
272 self.backgroundService.enqueueRequest( |
281 "batch_radon_raw", "Python3", "", data["Python3"] |
273 "batch_radon_raw", "Python3", "", data["Python3"] |
282 ) |
274 ) |
283 self.batchesFinished["raw"] = False |
275 self.batchesFinished["raw"] = False |
300 @type str |
292 @type str |
301 @param source string containing the code |
293 @param source string containing the code |
302 @type str |
294 @type str |
303 """ |
295 """ |
304 if lang is None: |
296 if lang is None: |
305 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
297 lang = "Python3" |
306 if lang == "Python3": |
298 if lang == "Python3": |
307 self.backgroundService.enqueueRequest("radon_mi", lang, filename, [source]) |
299 self.backgroundService.enqueueRequest("radon_mi", lang, filename, [source]) |
308 |
300 |
309 def maintainabilityIndexBatch(self, argumentsList): |
301 def maintainabilityIndexBatch(self, argumentsList): |
310 """ |
302 """ |
317 """ |
309 """ |
318 data = { |
310 data = { |
319 "Python3": [], |
311 "Python3": [], |
320 } |
312 } |
321 for filename, source in argumentsList: |
313 for filename, source in argumentsList: |
322 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
314 data["Python3"].append((filename, source)) |
323 if lang == "Python3": |
|
324 data[lang].append((filename, source)) |
|
325 |
315 |
326 self.queuedBatches["mi"] = [] |
316 self.queuedBatches["mi"] = [] |
327 if data["Python3"]: |
317 if data["Python3"]: |
328 self.queuedBatches["mi"].append("Python3") |
318 self.queuedBatches["mi"].append("Python3") |
329 self.backgroundService.enqueueRequest( |
319 self.backgroundService.enqueueRequest( |
349 @type str |
339 @type str |
350 @param source string containing the code |
340 @param source string containing the code |
351 @type str |
341 @type str |
352 """ |
342 """ |
353 if lang is None: |
343 if lang is None: |
354 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
344 lang = "Python3" |
355 if lang == "Python3": |
345 if lang == "Python3": |
356 self.backgroundService.enqueueRequest("radon_cc", lang, filename, [source]) |
346 self.backgroundService.enqueueRequest("radon_cc", lang, filename, [source]) |
357 |
347 |
358 def cyclomaticComplexityBatch(self, argumentsList): |
348 def cyclomaticComplexityBatch(self, argumentsList): |
359 """ |
349 """ |
366 """ |
356 """ |
367 data = { |
357 data = { |
368 "Python3": [], |
358 "Python3": [], |
369 } |
359 } |
370 for filename, source in argumentsList: |
360 for filename, source in argumentsList: |
371 lang = "Python{0}".format(determinePythonVersion(filename, source)) |
361 data["Python3"].append((filename, source)) |
372 if lang == "Python3": |
|
373 data[lang].append((filename, source)) |
|
374 |
362 |
375 self.queuedBatches["raw"] = [] |
363 self.queuedBatches["raw"] = [] |
376 if data["Python3"]: |
364 if data["Python3"]: |
377 self.queuedBatches["cc"].append("Python3") |
365 self.queuedBatches["cc"].append("Python3") |
378 self.backgroundService.enqueueRequest( |
366 self.backgroundService.enqueueRequest( |