1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Pass plugin's folder to plugin_start()

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

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"
```

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: