mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 08:17:13 +03:00
Pass plugin's folder to plugin_start()
This commit is contained in:
parent
7e8457f74c
commit
b8a7d143d4
@ -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.
|
EDMC will import the `load.py` file as a module and then call the `plugin_start()` function.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def plugin_start():
|
def plugin_start(plugin_dir):
|
||||||
"""
|
"""
|
||||||
Load this plugin into EDMC
|
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"
|
return "Test"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
5
plug.py
5
plug.py
@ -83,7 +83,10 @@ class Plugin(object):
|
|||||||
with open(loadfile, 'rb') as plugfile:
|
with open(loadfile, 'rb') as plugfile:
|
||||||
module = imp.load_module('plugin_%s' % name.encode('ascii', 'replace').replace('.', '_'), plugfile, loadfile.encode(sys.getfilesystemencoding()),
|
module = imp.load_module('plugin_%s' % name.encode('ascii', 'replace').replace('.', '_'), plugfile, loadfile.encode(sys.getfilesystemencoding()),
|
||||||
('.py', 'r', imp.PY_SOURCE))
|
('.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.name = newname and unicode(newname) or name
|
||||||
self.module = module
|
self.module = module
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user