PluginVulture.py

branch
eric7
changeset 79
47e46cd3bb23
parent 76
69f611e5efbb
child 83
7a6fb6e896e0
--- a/PluginVulture.py	Tue May 25 19:30:18 2021 +0200
+++ b/PluginVulture.py	Tue May 25 19:36:03 2021 +0200
@@ -9,10 +9,10 @@
 
 import os
 
-from PyQt5.QtCore import pyqtSignal, QObject, QTranslator
+from PyQt6.QtCore import pyqtSignal, QObject, QTranslator
 
-from E5Gui.E5Application import e5App
-from E5Gui.E5Action import E5Action
+from EricWidgets.EricApplication import ericApp
+from EricGui.EricAction import EricAction
 
 import Preferences
 from Utilities import determinePythonVersion
@@ -22,12 +22,12 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "5.0.0"
+version = "1.0.0"
 className = "VulturePlugin"
 packageName = "VultureChecker"
-shortDescription = "Plug-in to detect unused code using the vulture library"
+shortDescription = "Plug-in to detect unused code using the 'vulture' library"
 longDescription = (
-    """Plug-in to detect unused code using the vulture library."""
+    """Plug-in to detect unused code using the 'vulture' library."""
 )
 needsRestart = False
 pyqtApi = 2
@@ -53,13 +53,14 @@
         """
         Constructor
         
-        @param ui reference to the user interface object (UI.UserInterface)
+        @param ui reference to the user interface object
+        @type UserInterface
         """
         super().__init__(ui)
         self.__ui = ui
         self.__initialize()
         
-        self.backgroundService = e5App().getObject("BackgroundService")
+        self.backgroundService = ericApp().getObject("BackgroundService")
         
         path = os.path.join(os.path.dirname(__file__), packageName)
         self.backgroundService.serviceConnect(
@@ -196,14 +197,15 @@
         """
         Public method to activate this plug-in.
         
-        @return tuple of None and activation status (boolean)
+        @return tuple of None and activation status
+        @rtype tuple of (None, bool)
         """
         global error
         error = ""     # clear previous error
         
-        menu = e5App().getObject("Project").getMenu("Checks")
+        menu = ericApp().getObject("Project").getMenu("Checks")
         if menu:
-            self.__projectAct = E5Action(
+            self.__projectAct = EricAction(
                 self.tr('Check Unused Code'),
                 self.tr('&Unused Code...'), 0, 0,
                 self, 'project_check_vulture')
@@ -215,11 +217,11 @@
             ))
             self.__projectAct.triggered.connect(
                 self.__projectVultureCheck)
-            e5App().getObject("Project").addE5Actions([self.__projectAct])
+            ericApp().getObject("Project").addEricActions([self.__projectAct])
             menu.addAction(self.__projectAct)
         
-        e5App().getObject("Project").showMenu.connect(self.__projectShowMenu)
-        e5App().getObject("Project").projectClosed.connect(
+        ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu)
+        ericApp().getObject("Project").projectClosed.connect(
             self.__projectClosed)
         
         return None, True
@@ -228,15 +230,15 @@
         """
         Public method to deactivate this plug-in.
         """
-        e5App().getObject("Project").showMenu.disconnect(
+        ericApp().getObject("Project").showMenu.disconnect(
             self.__projectShowMenu)
-        e5App().getObject("Project").projectClosed.disconnect(
+        ericApp().getObject("Project").projectClosed.disconnect(
             self.__projectClosed)
         
-        menu = e5App().getObject("Project").getMenu("Checks")
+        menu = ericApp().getObject("Project").getMenu("Checks")
         if menu is not None and self.__projectAct is not None:
             menu.removeAction(self.__projectAct)
-            e5App().getObject("Project").removeE5Actions(
+            ericApp().getObject("Project").removeEricActions(
                 [self.__projectAct])
         
         self.__initialize()
@@ -255,7 +257,7 @@
                 loaded = translator.load(translation, locale_dir)
                 if loaded:
                     self.__translator = translator
-                    e5App().installTranslator(self.__translator)
+                    ericApp().installTranslator(self.__translator)
                 else:
                     print("Warning: translation file '{0}' could not be"
                           " loaded.".format(translation))
@@ -273,7 +275,7 @@
         """
         if menuName == "Check" and self.__projectAct is not None:
             self.__projectAct.setEnabled(
-                e5App().getObject("Project")
+                ericApp().getObject("Project")
                 .getProjectLanguage() == "Python3"
             )
     
@@ -281,14 +283,16 @@
         """
         Private slot used to check the project for unused code.
         """
-        project = e5App().getObject("Project")
+        project = ericApp().getObject("Project")
         project.saveAllScripts()
         ppath = project.getProjectPath()
-        files = [os.path.join(ppath, file_)
-                 for file_ in project.getSources()
-                 if file_.endswith(
-                     tuple(Preferences.getPython("Python3Extensions")) +
-                     tuple(Preferences.getPython("PythonExtensions")))]
+        files = [
+            os.path.join(ppath, file_)
+            for file_ in project.getSources()
+            if file_.endswith(
+                tuple(Preferences.getPython("Python3Extensions"))
+            )
+        ]
         
         if self.__projectVultureCheckerDialog is None:
             from VultureChecker.VultureCheckerDialog import (

eric ide

mercurial