:type plugin_mapping: dict :param plugin_mapping: A dict of plugin name to import path, e.g. ``{"plugingName": "package.modulefoo"}``. :type event_hooks: ``EventHooks`` :param event_hooks: Event hook emitter. If one if not provided, a LazyInitEmitter will be creat
(plugin_mapping, event_hooks=None, include_builtins=True)
| 27 | |
| 28 | |
| 29 | def load_plugins(plugin_mapping, event_hooks=None, include_builtins=True): |
| 30 | """ |
| 31 | |
| 32 | :type plugin_mapping: dict |
| 33 | :param plugin_mapping: A dict of plugin name to import path, |
| 34 | e.g. ``{"plugingName": "package.modulefoo"}``. |
| 35 | |
| 36 | :type event_hooks: ``EventHooks`` |
| 37 | :param event_hooks: Event hook emitter. If one if not provided, |
| 38 | a LazyInitEmitter will be created and returned. Otherwise, the |
| 39 | passed in ``event_hooks`` will be used to initialize plugins. |
| 40 | |
| 41 | :type include_builtins: bool |
| 42 | :param include_builtins: If True, the built-in plugin registry will be |
| 43 | loaded into the emitter. |
| 44 | |
| 45 | :rtype: LazyInitEmitter |
| 46 | :return: An event emitter object. |
| 47 | |
| 48 | """ |
| 49 | if event_hooks is None: |
| 50 | event_hooks = LazyInitEmitter() |
| 51 | if include_builtins: |
| 52 | _load_registry(event_hooks) |
| 53 | plugin_path = plugin_mapping.pop(CLI_LEGACY_PLUGIN_PATH, None) |
| 54 | if plugin_path is not None: |
| 55 | _add_plugin_path_to_sys_path(plugin_path) |
| 56 | _load_plugins(plugin_mapping, event_hooks) |
| 57 | else: |
| 58 | log.debug( |
| 59 | "cli_legacy_plugin_path not defined in plugin section. Not " |
| 60 | "importing additional plugins." |
| 61 | ) |
| 62 | return event_hooks |
| 63 | |
| 64 | |
| 65 | @singledispatch |
no test coverage detected