Add branch_name_in_commit plugin
[fast-export.git] / pluginloader / __init__.py
blob82373a5ea5fa7cbb7822c8d0243965e8aa016f2b
1 import os
2 import imp
3 PluginFolder = os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","plugins")
4 MainModule = "__init__"
6 def get_plugin(name, plugin_path):
7 search_dirs = [PluginFolder]
8 if plugin_path:
9 search_dirs = [plugin_path] + search_dirs
10 for dir in search_dirs:
11 location = os.path.join(dir, name)
12 if not os.path.isdir(location) or not MainModule + ".py" in os.listdir(location):
13 continue
14 info = imp.find_module(MainModule, [location])
15 return {"name": name, "info": info, "path": location}
16 raise Exception("Could not find plugin with name " + name)
18 def load_plugin(plugin):
19 return imp.load_module(MainModule, *plugin["info"])