MCPcopy Create free account
hub / github.com/Fadi002/de4py / load_plugins

Function load_plugins

plugins/plugins.py:14–39  ·  view source on GitHub ↗

Loads all plugins from the plugins directory. Isolates failures per plugin to ensure application startup is not affected.

()

Source from the content-addressed store, hash-verified

12logger = logging.getLogger(__name__)
13
14def load_plugins() -> List[Dict[str, Any]]:
15 """
16 Loads all plugins from the plugins directory.
17 Isolates failures per plugin to ensure application startup is not affected.
18 """
19 plugins_dir = Path(__file__).parent
20 loaded_plugins = []
21
22 # Iterate through all .py files in the plugins folder
23 for plugin_file in plugins_dir.glob("*.py"):
24 if plugin_file.name in ("__init__.py", "plugins.py"):
25 continue
26
27 try:
28 plugin_instance = _load_single_plugin(plugin_file)
29 if plugin_instance:
30 plugin_type = "deobfuscator" if isinstance(plugin_instance, DeobfuscatorPlugin) else "theme"
31 loaded_plugins.append({
32 "type": plugin_type,
33 "instance": plugin_instance
34 })
35 logger.debug(f"Successfully loaded plugin: {getattr(plugin_instance, 'name', plugin_file.stem)}")
36 except Exception as e:
37 logger.error(f"Failed to load plugin {plugin_file.name}: {e}")
38
39 return loaded_plugins
40
41def _load_single_plugin(file_path: Path):
42 """Loads a single plugin from a file path using the register contract."""

Callers 2

mainFunction · 0.90
set_transparent_uiMethod · 0.90

Calls 1

_load_single_pluginFunction · 0.85

Tested by

no test coverage detected