Download app/services/plugin_manager.py from rastof9/fb: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/rastof9/fb/resolve/main/app/services/plugin_manager.py
- Command line
-
hf download hf://spaces/rastof9/fb/app/services/plugin_manager.py
-
curl -L -o plugin_manager.py https://huggingface.co/spaces/rastof9/fb/resolve/main/app/services/plugin_manager.py
710 Bytes
| import importlib.util | |
| from pathlib import Path | |
| class PluginManager: | |
| def __init__(self): | |
| self.plugins = {} | |
| def load_plugins(self, directory="plugins"): | |
| for plugin_file in Path(directory).glob("*.py"): | |
| spec = importlib.util.spec_from_file_location(plugin_file.stem, plugin_file) | |
| module = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(module) | |
| self.plugins[plugin_file.stem] = module | |
| def run_analysis(self, ad): | |
| results = {} | |
| for name, plugin in self.plugins.items(): | |
| if hasattr(plugin, "analyze"): | |
| results[name] = plugin.analyze(ad) | |
| return results |