Pass plugin's folder to plugin_start()

This commit is contained in:
Jonathan Harris committed 2018-08-09 00:47:28 +01:00
1 parent 7e8457f74c
commit b8a7d143d4
2 files changed
+6 -3

No files matched your search

+2 -2
View File
@@ -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"
```
+4 -1
View File
@@ -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: