eric6/PluginManager/PluginManager.py

changeset 7023
b025e93cc27d
parent 6942
2602857055c5
child 7192
a22eee00b052
equal deleted inserted replaced
7022:a5f9f601b6ac 7023:b025e93cc27d
397 if not hasattr(module, "python2Compatible"): 397 if not hasattr(module, "python2Compatible"):
398 module.error = self.tr( 398 module.error = self.tr(
399 "Module is missing the Python2 compatibility flag." 399 "Module is missing the Python2 compatibility flag."
400 " Please update.") 400 " Please update.")
401 compatible = False 401 compatible = False
402 elif not getattr(module, "python2Compatible"): 402 elif not getattr(module, "python2Compatible", True):
403 module.error = self.tr( 403 module.error = self.tr(
404 "Module is not Python2 compatible.") 404 "Module is not Python2 compatible.")
405 compatible = False 405 compatible = False
406 else: 406 else:
407 compatible = True 407 compatible = True
408 if not compatible: 408 if not compatible:
409 self.__failedModules[name] = module 409 self.__failedModules[name] = module
410 raise PluginPy2IncompatibleError(name) 410 raise PluginPy2IncompatibleError(name)
411 if getattr(module, "autoactivate"): 411 if getattr(module, "autoactivate", False):
412 self.__inactiveModules[name] = module 412 self.__inactiveModules[name] = module
413 else: 413 else:
414 if not hasattr(module, "pluginType") or \ 414 if not hasattr(module, "pluginType") or \
415 not hasattr(module, "pluginTypename"): 415 not hasattr(module, "pluginTypename"):
416 module.error = \ 416 module.error = \
536 except KeyError: 536 except KeyError:
537 return 537 return
538 538
539 if not self.__canActivatePlugin(module): 539 if not self.__canActivatePlugin(module):
540 raise PluginActivationError(module.eric6PluginModuleName) 540 raise PluginActivationError(module.eric6PluginModuleName)
541 version = getattr(module, "version") 541 version = getattr(module, "version", "0.0.0")
542 className = getattr(module, "className") 542 className = getattr(module, "className", "")
543 pluginClass = getattr(module, className) 543 pluginClass = getattr(module, className)
544 pluginObject = None 544 pluginObject = None
545 if name not in self.__onDemandInactivePlugins: 545 if name not in self.__onDemandInactivePlugins:
546 pluginObject = pluginClass(self.__ui) 546 pluginObject = pluginClass(self.__ui)
547 pluginObject.eric6PluginModule = module 547 pluginObject.eric6PluginModule = module
606 except KeyError: 606 except KeyError:
607 return None 607 return None
608 608
609 if not self.__canActivatePlugin(module): 609 if not self.__canActivatePlugin(module):
610 raise PluginActivationError(module.eric6PluginModuleName) 610 raise PluginActivationError(module.eric6PluginModuleName)
611 version = getattr(module, "version") 611 version = getattr(module, "version", "0.0.0")
612 className = getattr(module, "className") 612 className = getattr(module, "className", "")
613 pluginClass = getattr(module, className) 613 pluginClass = getattr(module, className)
614 pluginObject = None 614 pluginObject = None
615 if onDemand and name in self.__onDemandInactivePlugins: 615 if onDemand and name in self.__onDemandInactivePlugins:
616 pluginObject = self.__onDemandInactivePlugins[name] 616 pluginObject = self.__onDemandInactivePlugins[name]
617 elif not onDemand and name in self.__inactivePlugins: 617 elif not onDemand and name in self.__inactivePlugins:
675 raise PluginModuleFormatError( 675 raise PluginModuleFormatError(
676 module.eric6PluginModuleName, "version") 676 module.eric6PluginModuleName, "version")
677 if not hasattr(module, "className"): 677 if not hasattr(module, "className"):
678 raise PluginModuleFormatError( 678 raise PluginModuleFormatError(
679 module.eric6PluginModuleName, "className") 679 module.eric6PluginModuleName, "className")
680 className = getattr(module, "className") 680 className = getattr(module, "className", "")
681 if not hasattr(module, className): 681 if not className or not hasattr(module, className):
682 raise PluginModuleFormatError( 682 raise PluginModuleFormatError(
683 module.eric6PluginModuleName, className) 683 module.eric6PluginModuleName, className)
684 pluginClass = getattr(module, className) 684 pluginClass = getattr(module, className)
685 if not hasattr(pluginClass, "__init__"): 685 if not hasattr(pluginClass, "__init__"):
686 raise PluginClassFormatError( 686 raise PluginClassFormatError(
763 @keyparam maybeActive flag indicating, that the plugin may be active 763 @keyparam maybeActive flag indicating, that the plugin may be active
764 already (boolean) 764 already (boolean)
765 @return reference to the initialized plugin object 765 @return reference to the initialized plugin object
766 """ 766 """
767 for name, module in list(self.__onDemandInactiveModules.items()): 767 for name, module in list(self.__onDemandInactiveModules.items()):
768 if getattr(module, "pluginType") == type_ and \ 768 if getattr(module, "pluginType", "") == type_ and \
769 getattr(module, "pluginTypename") == typename: 769 getattr(module, "pluginTypename", "") == typename:
770 return self.activatePlugin(name, onDemand=True) 770 return self.activatePlugin(name, onDemand=True)
771 771
772 if maybeActive: 772 if maybeActive:
773 for name, module in list(self.__onDemandActiveModules.items()): 773 for name, module in list(self.__onDemandActiveModules.items()):
774 if getattr(module, "pluginType") == type_ and \ 774 if getattr(module, "pluginType", "") == type_ and \
775 getattr(module, "pluginTypename") == typename: 775 getattr(module, "pluginTypename", "") == typename:
776 self.deactivatePlugin(name, onDemand=True) 776 self.deactivatePlugin(name, onDemand=True)
777 return self.activatePlugin(name, onDemand=True) 777 return self.activatePlugin(name, onDemand=True)
778 778
779 return None 779 return None
780 780
928 """ 928 """
929 pluginDict = {} 929 pluginDict = {}
930 930
931 for module in list(self.__onDemandActiveModules.values()) + \ 931 for module in list(self.__onDemandActiveModules.values()) + \
932 list(self.__onDemandInactiveModules.values()): 932 list(self.__onDemandInactiveModules.values()):
933 if getattr(module, "pluginType") == type_ and \ 933 if getattr(module, "pluginType", "") == type_ and \
934 getattr(module, "error", "") == "": 934 getattr(module, "error", "") == "":
935 plugin_name = getattr(module, "pluginTypename") 935 plugin_name = getattr(module, "pluginTypename", "")
936 if hasattr(module, "displayString"): 936 if plugin_name:
937 try: 937 if hasattr(module, "displayString"):
938 disp = module.displayString() 938 try:
939 except TypeError: 939 disp = module.displayString()
940 disp = getattr(module, "displayString") 940 except TypeError:
941 if disp != "": 941 disp = getattr(module, "displayString", "")
942 pluginDict[plugin_name] = disp 942 if disp != "":
943 else: 943 pluginDict[plugin_name] = disp
944 pluginDict[plugin_name] = plugin_name 944 else:
945 pluginDict[plugin_name] = plugin_name
945 946
946 return pluginDict 947 return pluginDict
947 948
948 def getPluginPreviewPixmap(self, type_, name): 949 def getPluginPreviewPixmap(self, type_, name):
949 """ 950 """
953 @param name name of the plugin type (string) 954 @param name name of the plugin type (string)
954 @return preview pixmap (QPixmap) 955 @return preview pixmap (QPixmap)
955 """ 956 """
956 for module in list(self.__onDemandActiveModules.values()) + \ 957 for module in list(self.__onDemandActiveModules.values()) + \
957 list(self.__onDemandInactiveModules.values()): 958 list(self.__onDemandInactiveModules.values()):
958 if getattr(module, "pluginType") == type_ and \ 959 if getattr(module, "pluginType", "") == type_ and \
959 getattr(module, "pluginTypename") == name: 960 getattr(module, "pluginTypename", "") == name:
960 if hasattr(module, "previewPix"): 961 if hasattr(module, "previewPix"):
961 return module.previewPix() 962 return module.previewPix()
962 else: 963 else:
963 return QPixmap() 964 return QPixmap()
964 965
1132 """ 1133 """
1133 vcsDict = {} 1134 vcsDict = {}
1134 1135
1135 for module in list(self.__onDemandActiveModules.values()) + \ 1136 for module in list(self.__onDemandActiveModules.values()) + \
1136 list(self.__onDemandInactiveModules.values()): 1137 list(self.__onDemandInactiveModules.values()):
1137 if getattr(module, "pluginType") == "version_control": 1138 if getattr(module, "pluginType", "") == "version_control":
1138 if hasattr(module, "getVcsSystemIndicator"): 1139 if hasattr(module, "getVcsSystemIndicator"):
1139 res = module.getVcsSystemIndicator() 1140 res = module.getVcsSystemIndicator()
1140 for indicator, vcsData in list(res.items()): 1141 for indicator, vcsData in list(res.items()):
1141 if indicator in vcsDict: 1142 if indicator in vcsDict:
1142 vcsDict[indicator].append(vcsData) 1143 vcsDict[indicator].append(vcsData)
1148 def deactivateVcsPlugins(self): 1149 def deactivateVcsPlugins(self):
1149 """ 1150 """
1150 Public method to deactivated all activated VCS plugins. 1151 Public method to deactivated all activated VCS plugins.
1151 """ 1152 """
1152 for name, module in list(self.__onDemandActiveModules.items()): 1153 for name, module in list(self.__onDemandActiveModules.items()):
1153 if getattr(module, "pluginType") == "version_control": 1154 if getattr(module, "pluginType", "") == "version_control":
1154 self.deactivatePlugin(name, True) 1155 self.deactivatePlugin(name, True)
1155 1156
1156 ######################################################################## 1157 ########################################################################
1157 ## Methods for the creation of the plug-ins download directory 1158 ## Methods for the creation of the plug-ins download directory
1158 ######################################################################## 1159 ########################################################################

eric ide

mercurial