eric6/PluginManager/PluginManager.py

changeset 7255
d595f6f9cbf8
parent 7229
53054eb5b15a
child 7360
9190402e4505
diff -r f00d825fbdb3 -r d595f6f9cbf8 eric6/PluginManager/PluginManager.py
--- a/eric6/PluginManager/PluginManager.py	Sat Sep 21 17:41:22 2019 +0200
+++ b/eric6/PluginManager/PluginManager.py	Sat Sep 21 18:30:02 2019 +0200
@@ -12,11 +12,13 @@
 import imp
 import zipfile
 
-from PyQt5.QtCore import pyqtSignal, QObject, QDate, QFile, QFileInfo, QUrl, \
-    QIODevice
+from PyQt5.QtCore import (
+    pyqtSignal, QObject, QDate, QFile, QFileInfo, QUrl, QIODevice
+)
 from PyQt5.QtGui import QPixmap
-from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, \
-    QNetworkReply
+from PyQt5.QtNetwork import (
+    QNetworkAccessManager, QNetworkRequest, QNetworkReply
+)
 
 from E5Gui import E5MessageBox
 from E5Gui.E5Application import e5App
@@ -28,9 +30,10 @@
 except ImportError:
     SSL_AVAILABLE = False
 
-from .PluginExceptions import PluginPathError, PluginModulesError, \
-    PluginLoadError, PluginActivationError, PluginModuleFormatError, \
-    PluginClassFormatError
+from .PluginExceptions import (
+    PluginPathError, PluginModulesError, PluginLoadError,
+    PluginActivationError, PluginModuleFormatError, PluginClassFormatError
+)
 
 import UI.PixmapCache
 
@@ -144,8 +147,8 @@
         
         self.__checkPluginsDownloadDirectory()
         
-        self.pluginRepositoryFile = \
-            os.path.join(Utilities.getConfigDir(), "PluginRepository")
+        self.pluginRepositoryFile = os.path.join(Utilities.getConfigDir(),
+                                                 "PluginRepository")
         
         # attributes for the network objects
         self.__networkManager = QNetworkAccessManager(self)
@@ -166,8 +169,10 @@
         """
         Public method to finalize the setup of the plugin manager.
         """
-        for module in list(self.__onDemandInactiveModules.values()) + \
-                list(self.__onDemandActiveModules.values()):
+        for module in (
+            list(self.__onDemandInactiveModules.values()) +
+            list(self.__onDemandActiveModules.values())
+        ):
             if hasattr(module, "moduleSetup"):
                 module.moduleSetup()
         
@@ -218,8 +223,10 @@
             except IOError:
                 del self.pluginDirs["user"]
         
-        if not os.path.exists(self.pluginDirs["global"]) and \
-           os.access(Utilities.getPythonModulesDirectory(), os.W_OK):
+        if (
+            not os.path.exists(self.pluginDirs["global"]) and
+            os.access(Utilities.getPythonModulesDirectory(), os.W_OK)
+        ):
             # create the global plugins directory
             os.mkdir(self.pluginDirs["global"], 0o755)
             fname = os.path.join(self.pluginDirs["global"], "__init__.py")
@@ -248,19 +255,21 @@
         
         @return flag indicating the availability of plugins (boolean)
         """
-        if self.__develPluginFile and \
-                not os.path.exists(self.__develPluginFile):
+        if (
+            self.__develPluginFile and
+            not os.path.exists(self.__develPluginFile)
+        ):
             return False
         
         self.__foundCoreModules = self.getPluginModules(
             self.pluginDirs["eric6"])
         if Preferences.getPluginManager("ActivateExternal"):
             if "global" in self.pluginDirs:
-                self.__foundGlobalModules = \
-                    self.getPluginModules(self.pluginDirs["global"])
+                self.__foundGlobalModules = self.getPluginModules(
+                    self.pluginDirs["global"])
             if "user" in self.pluginDirs:
-                self.__foundUserModules = \
-                    self.getPluginModules(self.pluginDirs["user"])
+                self.__foundUserModules = self.getPluginModules(
+                    self.pluginDirs["user"])
         
         return len(self.__foundCoreModules + self.__foundGlobalModules +
                    self.__foundUserModules) > 0
@@ -309,22 +318,26 @@
         """
         develPluginName = ""
         if self.__develPluginFile:
-            develPluginPath, develPluginName = \
-                Utilities.splitPath(self.__develPluginFile)
+            develPluginPath, develPluginName = Utilities.splitPath(
+                self.__develPluginFile)
             if self.isValidPluginName(develPluginName):
                 develPluginName = develPluginName[:-3]
         
         for pluginName in self.__foundGlobalModules:
             # user and core plug-ins have priority
-            if pluginName not in self.__foundUserModules and \
-               pluginName not in self.__foundCoreModules and \
-               pluginName != develPluginName:
+            if (
+                pluginName not in self.__foundUserModules and
+                pluginName not in self.__foundCoreModules and
+                pluginName != develPluginName
+            ):
                 self.loadPlugin(pluginName, self.pluginDirs["global"])
         
         for pluginName in self.__foundUserModules:
             # core plug-ins have priority
-            if pluginName not in self.__foundCoreModules and \
-               pluginName != develPluginName:
+            if (
+                pluginName not in self.__foundCoreModules and
+                pluginName != develPluginName
+            ):
                 self.loadPlugin(pluginName, self.pluginDirs["user"])
         
         for pluginName in self.__foundCoreModules:
@@ -350,15 +363,19 @@
         
         for pluginName in self.__foundGlobalModules:
             # user and core plug-ins have priority
-            if pluginName not in self.__foundUserModules and \
-               pluginName not in self.__foundCoreModules and \
-               pluginName.startswith("PluginDocumentationSets"):
+            if (
+                pluginName not in self.__foundUserModules and
+                pluginName not in self.__foundCoreModules and
+                pluginName.startswith("PluginDocumentationSets")
+            ):
                 self.loadPlugin(pluginName, self.pluginDirs["global"])
         
         for pluginName in self.__foundUserModules:
             # core plug-ins have priority
-            if pluginName not in self.__foundCoreModules and \
-               pluginName.startswith("PluginDocumentationSets"):
+            if (
+                pluginName not in self.__foundCoreModules and
+                pluginName.startswith("PluginDocumentationSets")
+            ):
                 self.loadPlugin(pluginName, self.pluginDirs["user"])
         
         for pluginName in self.__foundCoreModules:
@@ -392,11 +409,14 @@
             if getattr(module, "autoactivate", False):
                 self.__inactiveModules[name] = module
             else:
-                if not hasattr(module, "pluginType") or \
-                   not hasattr(module, "pluginTypename"):
-                    module.error = \
-                        self.tr("Module is missing the 'pluginType' "
-                                "and/or 'pluginTypename' attributes.")
+                if (
+                    not hasattr(module, "pluginType") or
+                    not hasattr(module, "pluginTypename")
+                ):
+                    module.error = self.tr(
+                        "Module is missing the 'pluginType' "
+                        "and/or 'pluginTypename' attributes."
+                    )
                     self.__failedModules[name] = module
                     raise PluginLoadError(name)
                 else:
@@ -482,8 +502,10 @@
         if not package:
             package = "__None__"
         for moduleName in list(sys.modules.keys())[:]:
-            if moduleName == pluginName or \
-                    moduleName.split(".")[0] in packages:
+            if (
+                moduleName == pluginName or
+                moduleName.split(".")[0] in packages
+            ):
                 found = True
                 del sys.modules[moduleName]
         return found
@@ -555,8 +577,10 @@
         if savedInactiveList is not None:
             inactiveList += [p for p in savedInactiveList
                              if p not in self.__disabledPlugins]
-        if self.__develPluginName is not None and \
-           self.__develPluginName in inactiveList:
+        if (
+            self.__develPluginName is not None and
+            self.__develPluginName in inactiveList
+        ):
             inactiveList.remove(self.__develPluginName)
         names = sorted(self.__inactiveModules.keys())
         for name in names:
@@ -743,14 +767,18 @@
         @return reference to the initialized plugin object
         """
         for name, module in list(self.__onDemandInactiveModules.items()):
-            if getattr(module, "pluginType", "") == type_ and \
-               getattr(module, "pluginTypename", "") == typename:
+            if (
+                getattr(module, "pluginType", "") == type_ and
+                getattr(module, "pluginTypename", "") == typename
+            ):
                 return self.activatePlugin(name, onDemand=True)
         
         if maybeActive:
             for name, module in list(self.__onDemandActiveModules.items()):
-                if getattr(module, "pluginType", "") == type_ and \
-                   getattr(module, "pluginTypename", "") == typename:
+                if (
+                    getattr(module, "pluginType", "") == type_ and
+                    getattr(module, "pluginTypename", "") == typename
+                ):
                     self.deactivatePlugin(name, onDemand=True)
                     return self.activatePlugin(name, onDemand=True)
         
@@ -906,10 +934,14 @@
         """
         pluginDict = {}
         
-        for module in list(self.__onDemandActiveModules.values()) + \
-                list(self.__onDemandInactiveModules.values()):
-            if getattr(module, "pluginType", "") == type_ and \
-               getattr(module, "error", "") == "":
+        for module in (
+            list(self.__onDemandActiveModules.values()) +
+            list(self.__onDemandInactiveModules.values())
+        ):
+            if (
+                getattr(module, "pluginType", "") == type_ and
+                getattr(module, "error", "") == ""
+            ):
                 plugin_name = getattr(module, "pluginTypename", "")
                 if plugin_name:
                     if hasattr(module, "displayString"):
@@ -932,10 +964,14 @@
         @param name name of the plugin type (string)
         @return preview pixmap (QPixmap)
         """
-        for module in list(self.__onDemandActiveModules.values()) + \
-                list(self.__onDemandInactiveModules.values()):
-            if getattr(module, "pluginType", "") == type_ and \
-               getattr(module, "pluginTypename", "") == name:
+        for module in (
+            list(self.__onDemandActiveModules.values()) +
+            list(self.__onDemandInactiveModules.values())
+        ):
+            if (
+                getattr(module, "pluginType", "") == type_ and
+                getattr(module, "pluginTypename", "") == name
+            ):
                 if hasattr(module, "previewPix"):
                     return module.previewPix()
                 else:
@@ -952,8 +988,10 @@
         """
         apis = []
         
-        for module in list(self.__activeModules.values()) + \
-                list(self.__onDemandActiveModules.values()):
+        for module in (
+            list(self.__activeModules.values()) +
+            list(self.__onDemandActiveModules.values())
+        ):
             if hasattr(module, "apiFiles"):
                 apis.extend(module.apiFiles(language))
         
@@ -969,8 +1007,10 @@
         @rtype dict (key: str, value: list of str)
         """
         helpFiles = {}
-        for module in list(self.__activeModules.values()) + \
-                list(self.__onDemandActiveModules.values()):
+        for module in (
+            list(self.__activeModules.values()) +
+            list(self.__onDemandActiveModules.values())
+        ):
             if hasattr(module, "helpFiles"):
                 helpFiles.update(module.helpFiles())
         
@@ -1012,14 +1052,18 @@
         """
         infos = []
         
-        for module in list(self.__activeModules.values()) + \
-                list(self.__inactiveModules.values()):
+        for module in (
+            list(self.__activeModules.values()) +
+            list(self.__inactiveModules.values())
+        ):
             if hasattr(module, "exeDisplayDataList"):
                 infos.extend(module.exeDisplayDataList())
             elif hasattr(module, "exeDisplayData"):
                 infos.append(module.exeDisplayData())
-        for module in list(self.__onDemandActiveModules.values()) + \
-                list(self.__onDemandInactiveModules.values()):
+        for module in (
+            list(self.__onDemandActiveModules.values()) +
+            list(self.__onDemandInactiveModules.values())
+        ):
             if hasattr(module, "exeDisplayDataList"):
                 infos.extend(module.exeDisplayDataList())
             elif hasattr(module, "exeDisplayData"):
@@ -1060,9 +1104,11 @@
         @return plug-in configuration data
         """
         configData = {}
-        for module in list(self.__activeModules.values()) + \
-            list(self.__onDemandActiveModules.values()) + \
-                list(self.__onDemandInactiveModules.values()):
+        for module in (
+            list(self.__activeModules.values()) +
+            list(self.__onDemandActiveModules.values()) +
+                list(self.__onDemandInactiveModules.values())
+        ):
             if hasattr(module, 'getConfigData'):
                 configData.update(module.getConfigData())
         return configData
@@ -1074,10 +1120,12 @@
         @param pluginName name of the plugin to check for (string)
         @return flag indicating, if the plugin is loaded (boolean)
         """
-        return pluginName in self.__activeModules or \
-            pluginName in self.__inactiveModules or \
-            pluginName in self.__onDemandActiveModules or \
+        return (
+            pluginName in self.__activeModules or
+            pluginName in self.__inactiveModules or
+            pluginName in self.__onDemandActiveModules or
             pluginName in self.__onDemandInactiveModules
+        )
         
     def isPluginActive(self, pluginName):
         """
@@ -1086,8 +1134,10 @@
         @param pluginName name of the plugin to check for (string)
         @return flag indicating, if the plugin is active (boolean)
         """
-        return pluginName in self.__activeModules or \
+        return (
+            pluginName in self.__activeModules or
             pluginName in self.__onDemandActiveModules
+        )
     
     ###########################################################################
     ## Specialized plug-in module handling methods below
@@ -1111,8 +1161,10 @@
         """
         vcsDict = {}
         
-        for module in list(self.__onDemandActiveModules.values()) + \
-                list(self.__onDemandInactiveModules.values()):
+        for module in (
+            list(self.__onDemandActiveModules.values()) +
+            list(self.__onDemandInactiveModules.values())
+        ):
             if getattr(module, "pluginType", "") == "version_control":
                 if hasattr(module, "getVcsSystemIndicator"):
                     res = module.getVcsSystemIndicator()
@@ -1206,9 +1258,11 @@
                 elif period == 2 and lastModifiedDate.daysTo(now) < 7:
                     # weekly
                     return
-                elif period == 3 and \
+                elif (
+                    period == 3 and
                     (lastModifiedDate.daysTo(now) <
-                     lastModifiedDate.daysInMonth()):
+                     lastModifiedDate.daysInMonth())
+                ):
                     # monthly
                     return
         
@@ -1371,11 +1425,12 @@
         
         @param type_ type of the plugin to clear private data for (string)
         """
-        for module in \
-            list(self.__onDemandActiveModules.values()) + \
-            list(self.__onDemandInactiveModules.values()) + \
-            list(self.__activeModules.values()) + \
-                list(self.__inactiveModules.values()):
+        for module in (
+            list(self.__onDemandActiveModules.values()) +
+            list(self.__onDemandInactiveModules.values()) +
+            list(self.__activeModules.values()) +
+            list(self.__inactiveModules.values())
+        ):
             if getattr(module, "pluginType", "") == type_:
                 if hasattr(module, "clearPrivateData"):
                     module.clearPrivateData()

eric ide

mercurial