64 @param parent reference to the parent object (QObject) |
64 @param parent reference to the parent object (QObject) |
65 @keyparam doLoadPlugins flag indicating, that plugins should |
65 @keyparam doLoadPlugins flag indicating, that plugins should |
66 be loaded (boolean) |
66 be loaded (boolean) |
67 @keyparam develPlugin filename of a plugin to be loaded for |
67 @keyparam develPlugin filename of a plugin to be loaded for |
68 development (string) |
68 development (string) |
|
69 @exception PluginPathError raised to indicate an invalid plug-in path |
69 """ |
70 """ |
70 super().__init__(parent) |
71 super().__init__(parent) |
71 |
72 |
72 self.__ui = parent |
73 self.__ui = parent |
73 self.__develPluginFile = develPlugin |
74 self.__develPluginFile = develPlugin |
126 |
127 |
127 def getPluginDir(self, key): |
128 def getPluginDir(self, key): |
128 """ |
129 """ |
129 Public method to get the path of a plugin directory. |
130 Public method to get the path of a plugin directory. |
130 |
131 |
|
132 @param key key of the plug-in directory (string) |
131 @return path of the requested plugin directory (string) |
133 @return path of the requested plugin directory (string) |
132 """ |
134 """ |
133 if key not in ["global", "user"]: |
135 if key not in ["global", "user"]: |
134 return None |
136 return None |
135 else: |
137 else: |
295 checks are added to the failed modules list. |
297 checks are added to the failed modules list. |
296 |
298 |
297 @param name name of the module to be loaded (string) |
299 @param name name of the module to be loaded (string) |
298 @param directory name of the plugin directory (string) |
300 @param directory name of the plugin directory (string) |
299 @param reload_ flag indicating to reload the module (boolean) |
301 @param reload_ flag indicating to reload the module (boolean) |
|
302 @exception PluginLoadError raised to indicate an issue loading |
|
303 the plug-in |
300 """ |
304 """ |
301 try: |
305 try: |
302 fname = "{0}.py".format(os.path.join(directory, name)) |
306 fname = "{0}.py".format(os.path.join(directory, name)) |
303 module = imp.load_source(name, fname) |
307 module = imp.load_source(name, fname) |
304 if not hasattr(module, "autoactivate"): |
308 if not hasattr(module, "autoactivate"): |
396 |
400 |
397 def initOnDemandPlugin(self, name): |
401 def initOnDemandPlugin(self, name): |
398 """ |
402 """ |
399 Public method to create a plugin object for the named on demand plugin. |
403 Public method to create a plugin object for the named on demand plugin. |
400 |
404 |
401 Note: The plugin is not activated. |
405 Note: The plug-in is not activated. |
|
406 |
|
407 @param name name of the plug-in (string) |
|
408 @exception PluginActivationError raised to indicate an issue during the |
|
409 plug-in activation |
402 """ |
410 """ |
403 try: |
411 try: |
404 try: |
412 try: |
405 module = self.__onDemandInactiveModules[name] |
413 module = self.__onDemandInactiveModules[name] |
406 except KeyError: |
414 except KeyError: |
407 return None |
415 return |
408 |
416 |
409 if not self.__canActivatePlugin(module): |
417 if not self.__canActivatePlugin(module): |
410 raise PluginActivationError(module.eric5PluginModuleName) |
418 raise PluginActivationError(module.eric5PluginModuleName) |
411 version = getattr(module, "version") |
419 version = getattr(module, "version") |
412 className = getattr(module, "className") |
420 className = getattr(module, "className") |
417 pluginObject.eric5PluginModule = module |
425 pluginObject.eric5PluginModule = module |
418 pluginObject.eric5PluginName = className |
426 pluginObject.eric5PluginName = className |
419 pluginObject.eric5PluginVersion = version |
427 pluginObject.eric5PluginVersion = version |
420 self.__onDemandInactivePlugins[name] = pluginObject |
428 self.__onDemandInactivePlugins[name] = pluginObject |
421 except PluginActivationError: |
429 except PluginActivationError: |
422 return None |
430 return |
423 |
431 |
424 def activatePlugins(self): |
432 def activatePlugins(self): |
425 """ |
433 """ |
426 Public method to activate all plugins having the "autoactivate" attribute |
434 Public method to activate all plugins having the "autoactivate" attribute |
427 set to True. |
435 set to True. |
443 |
451 |
444 @param name name of the module to be activated |
452 @param name name of the module to be activated |
445 @keyparam onDemand flag indicating activation of an |
453 @keyparam onDemand flag indicating activation of an |
446 on demand plugin (boolean) |
454 on demand plugin (boolean) |
447 @return reference to the initialized plugin object |
455 @return reference to the initialized plugin object |
|
456 @exception PluginActivationError raised to indicate an issue during the |
|
457 plug-in activation |
448 """ |
458 """ |
449 try: |
459 try: |
450 try: |
460 try: |
451 if onDemand: |
461 if onDemand: |
452 module = self.__onDemandInactiveModules[name] |
462 module = self.__onDemandInactiveModules[name] |
511 Private method to check, if a plugin can be activated. |
521 Private method to check, if a plugin can be activated. |
512 |
522 |
513 @param module reference to the module to be activated |
523 @param module reference to the module to be activated |
514 @return flag indicating, if the module satisfies all requirements |
524 @return flag indicating, if the module satisfies all requirements |
515 for being activated (boolean) |
525 for being activated (boolean) |
|
526 @exception PluginModuleFormatError raised to indicate an invalid |
|
527 plug-in module format |
|
528 @exception PluginClassFormatError raised to indicate an invalid |
|
529 plug-in class format |
516 """ |
530 """ |
517 try: |
531 try: |
518 if not hasattr(module, "version"): |
532 if not hasattr(module, "version"): |
519 raise PluginModuleFormatError(module.eric5PluginModuleName, "version") |
533 raise PluginModuleFormatError(module.eric5PluginModuleName, "version") |
520 if not hasattr(module, "className"): |
534 if not hasattr(module, "className"): |
853 <dd>dictionary key of the parent entry or None, if this defines a |
867 <dd>dictionary key of the parent entry or None, if this defines a |
854 toplevel entry.</dd> |
868 toplevel entry.</dd> |
855 <dt>reference to configuration page</dt> |
869 <dt>reference to configuration page</dt> |
856 <dd>This will be used by the configuration dialog and must always be None</dd> |
870 <dd>This will be used by the configuration dialog and must always be None</dd> |
857 </dl> |
871 </dl> |
|
872 |
|
873 @return plug-in configuration data |
858 """ |
874 """ |
859 configData = {} |
875 configData = {} |
860 for module in list(self.__activeModules.values()) + \ |
876 for module in list(self.__activeModules.values()) + \ |
861 list(self.__onDemandActiveModules.values()) + \ |
877 list(self.__onDemandActiveModules.values()) + \ |
862 list(self.__onDemandInactiveModules.values()): |
878 list(self.__onDemandInactiveModules.values()): |