fb / app /services /plugin_manager.py
rastof9's picture
Saving local changes before rebase
d488241
raw
history blame contribute delete
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