diff --git a/PLUGINS.md b/PLUGINS.md index b72149b5..6d60539c 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -22,11 +22,11 @@ Plugins are python files. The plugin folder must have a file named `load.py` tha EDMC will import the `load.py` file as a module and then call the `plugin_start()` function. ```python -def plugin_start(): +def plugin_start(plugin_dir): """ Load this plugin into EDMC """ - print "I am loaded!" + print "I am loaded! My plugin folder is {}".format(plugin_dir.encode("utf-8")) return "Test" ``` diff --git a/plug.py b/plug.py index e4e96b6a..01075644 100644 --- a/plug.py +++ b/plug.py @@ -83,7 +83,10 @@ class Plugin(object): with open(loadfile, 'rb') as plugfile: module = imp.load_module('plugin_%s' % name.encode('ascii', 'replace').replace('.', '_'), plugfile, loadfile.encode(sys.getfilesystemencoding()), ('.py', 'r', imp.PY_SOURCE)) - newname = module.plugin_start() + if module.plugin_start.func_code.co_argcount == 0: + newname = module.plugin_start() + else: + newname = module.plugin_start(os.path.dirname(loadfile)) self.name = newname and unicode(newname) or name self.module = module else: