PluginVulture.py

changeset 62
4a69da851bd2
parent 61
9d01e990bb27
child 64
b55bba526b8b
--- a/PluginVulture.py	Wed Jan 01 11:58:52 2020 +0100
+++ b/PluginVulture.py	Tue Jun 23 17:33:21 2020 +0200
@@ -7,8 +7,6 @@
 Module implementing the vulture plug-in.
 """
 
-from __future__ import unicode_literals
-
 import os
 
 from PyQt5.QtCore import pyqtSignal, QObject, QTranslator
@@ -24,7 +22,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "2.0.1"
+version = "3.0.0"
 className = "VulturePlugin"
 packageName = "VultureChecker"
 shortDescription = "Plug-in to detect unused code using the vulture library"
@@ -33,7 +31,6 @@
 )
 needsRestart = False
 pyqtApi = 2
-python2Compatible = True
 # End-Of-Header
 
 error = ""
@@ -65,29 +62,11 @@
         self.backgroundService = e5App().getObject("BackgroundService")
         
         path = os.path.join(os.path.dirname(__file__), packageName)
-        try:
-            self.backgroundService.serviceConnect(
-                'vulture', 'Python2', path, 'VultureCheckerService',
-                self.vultureCheckDone,
-                onErrorCallback=self.serviceErrorPy2,
-                onBatchDone=self.batchJobDone)
-            self.backgroundService.serviceConnect(
-                'vulture', 'Python3', path, 'VultureCheckerService',
-                self.vultureCheckDone,
-                onErrorCallback=self.serviceErrorPy3,
-                onBatchDone=self.batchJobDone)
-            self.hasBatch = True
-        except TypeError:
-            # backward compatibility for eric 6.0
-            self.backgroundService.serviceConnect(
-                'vulture', 'Python2', path, 'VultureCheckerService',
-                self.vultureCheckDone,
-                onErrorCallback=self.serviceErrorPy2)
-            self.backgroundService.serviceConnect(
-                'vulture', 'Python3', path, 'VultureCheckerService',
-                self.vultureCheckDone,
-                onErrorCallback=self.serviceErrorPy3)
-            self.hasBatch = False
+        self.backgroundService.serviceConnect(
+            'vulture', 'Python3', path, 'VultureCheckerService',
+            self.vultureCheckDone,
+            onErrorCallback=self.serviceErrorPy3,
+            onBatchDone=self.batchJobDone)
         
         self.queuedBatches = []
         self.batchesFinished = True
@@ -106,27 +85,6 @@
         """
         self.error.emit(fn, msg)
     
-    def serviceErrorPy2(self, fx, lang, fn, msg):
-        """
-        Public slot handling service errors for Python 2.
-        
-        @param fx service name
-        @type str
-        @param lang language
-        @type str
-        @param fn file name
-        @type str
-        @param msg message text
-        @type str
-        """
-        if fx in ['vulture', 'batch_vulture'] and \
-                lang == 'Python2':
-            if fx == 'vulture':
-                self.__serviceError(fn, msg)
-            else:
-                self.__serviceError(self.tr("Python 2 batch job"), msg)
-                self.batchJobDone(fx, lang)
-    
     def serviceErrorPy3(self, fx, lang, fn, msg):
         """
         Public slot handling service errors for Python 3.
@@ -140,8 +98,7 @@
         @param msg message text
         @type str
         """
-        if fx in ['vulture', 'batch_vulture'] and \
-                lang == 'Python3':
+        if fx in ['vulture', 'batch_vulture'] and lang == 'Python3':
             if fx == 'vulture':
                 self.__serviceError(fn, msg)
             else:
@@ -197,7 +154,7 @@
         """
         if lang is None:
             lang = 'Python{0}'.format(determinePythonVersion(filename, source))
-        if lang not in ['Python2', 'Python3']:
+        if lang != 'Python3':
             return
         
         self.backgroundService.enqueueRequest(
@@ -213,30 +170,27 @@
         @type (str, str)
         """
         data = {
-            "Python2": [],
             "Python3": [],
         }
         for filename, source in argumentsList:
             lang = 'Python{0}'.format(determinePythonVersion(filename, source))
-            if lang not in ['Python2', 'Python3']:
+            if lang != 'Python3':
                 continue
             else:
                 data[lang].append((filename, source))
         
         self.queuedBatches = []
-        for lang in ['Python2', 'Python3']:
-            if data[lang]:
-                self.queuedBatches.append(lang)
-                self.backgroundService.enqueueRequest('batch_vulture', lang,
-                                                      "", data[lang])
-                self.batchesFinished = False
+        if data['Python3']:
+            self.queuedBatches.append('Python3')
+            self.backgroundService.enqueueRequest(
+                'batch_vulture', 'Python3', "", data['Python3'])
+            self.batchesFinished = False
     
     def cancelVultureCheckBatch(self):
         """
         Public method to cancel all batch jobs.
         """
-        for lang in ['Python2', 'Python3']:
-            self.backgroundService.requestCancel('batch_vulture', lang)
+        self.backgroundService.requestCancel('batch_vulture', 'Python3')
     
     def activate(self):
         """
@@ -321,8 +275,9 @@
         if menuName == "Check":
             if self.__projectAct is not None:
                 self.__projectAct.setEnabled(
-                    e5App().getObject("Project").getProjectLanguage() in
-                    ["Python3", "Python2", "Python"])
+                    e5App().getObject("Project")
+                    .getProjectLanguage() == "Python3"
+                )
     
     def __projectVultureCheck(self):
         """
@@ -338,8 +293,9 @@
                      tuple(Preferences.getPython("PythonExtensions")))]
         
         if self.__projectVultureCheckerDialog is None:
-            from VultureChecker.VultureCheckerDialog import \
+            from VultureChecker.VultureCheckerDialog import (
                 VultureCheckerDialog
+            )
             self.__projectVultureCheckerDialog = VultureCheckerDialog(self)
         self.__projectVultureCheckerDialog.show()
         self.__projectVultureCheckerDialog.prepare(files, project)
@@ -348,7 +304,7 @@
         """
         Private slot to handle closing a project.
         """
-        self.__projectVultureCheckerDialog and \
+        if self.__projectVultureCheckerDialog:
             self.__projectVultureCheckerDialog.clear()
 
 #

eric ide

mercurial