Generates and returns a dictionary of plugins. :return: dictionary containing plugin name -> plugin module :raises ImportError: If a plugin could not be imported.
()
| 15 | |
| 16 | # TODO: Should this be renamed to "load_plugins()" since it actually imports the modules? |
| 17 | def get_plugin_information() -> dict: |
| 18 | """ |
| 19 | Generates and returns a dictionary of plugins. |
| 20 | :return: dictionary containing plugin name -> plugin module |
| 21 | :raises ImportError: If a plugin could not be imported. |
| 22 | """ |
| 23 | plugin_map = get_plugins() |
| 24 | # Import ALL of the decoders and print info about them before exiting |
| 25 | plugins = {} |
| 26 | for name, module in sorted(plugin_map.items(), key=operator.itemgetter(1)): |
| 27 | try: |
| 28 | module = import_module(module) |
| 29 | if not module.DshellPlugin: |
| 30 | continue |
| 31 | module = module.DshellPlugin() |
| 32 | plugins[name] = module |
| 33 | except Exception as e: |
| 34 | raise ImportError(f"Could not load {repr(module)} with error: {e}") |
| 35 | |
| 36 | return plugins |
no test coverage detected