eric6/PluginManager/PluginManager.py

changeset 7023
b025e93cc27d
parent 6942
2602857055c5
child 7192
a22eee00b052
--- a/eric6/PluginManager/PluginManager.py	Wed May 22 18:55:23 2019 +0200
+++ b/eric6/PluginManager/PluginManager.py	Wed May 22 18:56:15 2019 +0200
@@ -399,7 +399,7 @@
                         "Module is missing the Python2 compatibility flag."
                         " Please update.")
                     compatible = False
-                elif not getattr(module, "python2Compatible"):
+                elif not getattr(module, "python2Compatible", True):
                     module.error = self.tr(
                         "Module is not Python2 compatible.")
                     compatible = False
@@ -408,7 +408,7 @@
                 if not compatible:
                     self.__failedModules[name] = module
                     raise PluginPy2IncompatibleError(name)
-            if getattr(module, "autoactivate"):
+            if getattr(module, "autoactivate", False):
                 self.__inactiveModules[name] = module
             else:
                 if not hasattr(module, "pluginType") or \
@@ -538,8 +538,8 @@
             
             if not self.__canActivatePlugin(module):
                 raise PluginActivationError(module.eric6PluginModuleName)
-            version = getattr(module, "version")
-            className = getattr(module, "className")
+            version = getattr(module, "version", "0.0.0")
+            className = getattr(module, "className", "")
             pluginClass = getattr(module, className)
             pluginObject = None
             if name not in self.__onDemandInactivePlugins:
@@ -608,8 +608,8 @@
             
             if not self.__canActivatePlugin(module):
                 raise PluginActivationError(module.eric6PluginModuleName)
-            version = getattr(module, "version")
-            className = getattr(module, "className")
+            version = getattr(module, "version", "0.0.0")
+            className = getattr(module, "className", "")
             pluginClass = getattr(module, className)
             pluginObject = None
             if onDemand and name in self.__onDemandInactivePlugins:
@@ -677,8 +677,8 @@
             if not hasattr(module, "className"):
                 raise PluginModuleFormatError(
                     module.eric6PluginModuleName, "className")
-            className = getattr(module, "className")
-            if not hasattr(module, className):
+            className = getattr(module, "className", "")
+            if not className or not hasattr(module, className):
                 raise PluginModuleFormatError(
                     module.eric6PluginModuleName, className)
             pluginClass = getattr(module, className)
@@ -765,14 +765,14 @@
         @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)
         
@@ -930,18 +930,19 @@
         
         for module in list(self.__onDemandActiveModules.values()) + \
                 list(self.__onDemandInactiveModules.values()):
-            if getattr(module, "pluginType") == type_ and \
+            if getattr(module, "pluginType", "") == type_ and \
                getattr(module, "error", "") == "":
-                plugin_name = getattr(module, "pluginTypename")
-                if hasattr(module, "displayString"):
-                    try:
-                        disp = module.displayString()
-                    except TypeError:
-                        disp = getattr(module, "displayString")
-                    if disp != "":
-                        pluginDict[plugin_name] = disp
-                else:
-                    pluginDict[plugin_name] = plugin_name
+                plugin_name = getattr(module, "pluginTypename", "")
+                if plugin_name:
+                    if hasattr(module, "displayString"):
+                        try:
+                            disp = module.displayString()
+                        except TypeError:
+                            disp = getattr(module, "displayString", "")
+                        if disp != "":
+                            pluginDict[plugin_name] = disp
+                    else:
+                        pluginDict[plugin_name] = plugin_name
         
         return pluginDict
         
@@ -955,8 +956,8 @@
         """
         for module in list(self.__onDemandActiveModules.values()) + \
                 list(self.__onDemandInactiveModules.values()):
-            if getattr(module, "pluginType") == type_ and \
-               getattr(module, "pluginTypename") == name:
+            if getattr(module, "pluginType", "") == type_ and \
+               getattr(module, "pluginTypename", "") == name:
                 if hasattr(module, "previewPix"):
                     return module.previewPix()
                 else:
@@ -1134,7 +1135,7 @@
         
         for module in list(self.__onDemandActiveModules.values()) + \
                 list(self.__onDemandInactiveModules.values()):
-            if getattr(module, "pluginType") == "version_control":
+            if getattr(module, "pluginType", "") == "version_control":
                 if hasattr(module, "getVcsSystemIndicator"):
                     res = module.getVcsSystemIndicator()
                     for indicator, vcsData in list(res.items()):
@@ -1150,7 +1151,7 @@
         Public method to deactivated all activated VCS plugins.
         """
         for name, module in list(self.__onDemandActiveModules.items()):
-            if getattr(module, "pluginType") == "version_control":
+            if getattr(module, "pluginType", "") == "version_control":
                 self.deactivatePlugin(name, True)
     
     ########################################################################

eric ide

mercurial