代码拉取完成,页面将自动刷新
*
* Readme for 'addonpy'
*
Description
------------
#
# Note: I have not checked it with Threading!
#
This is simple addon / plugin framework in python for python files. This is pure python module.
Main purpose of 'addonpy' is to give developer simple addon /plugin interface
- project specific config file to define addon location and functions to validate in each addon
- comes with own run_manager, which can execute functions within addon in given order
- either configure with run_manger instance
- or specify when executing particular addon
- or ask it to pick up from addon`s meta data
- obviously, you can run individual functions as you want without run_manger
** Note: make sure you run within try..except..finally block **
Works On
---------
I have tested it on below versions
- 2.7.6
- 3.4.1
Addon Guidelines
-----------------
Naming:
- Use CamelCase
- Every Addon should have 'Addon' in name
Organizing & Writing:
- Python file name and class name should be same!
e.g. LoadConfigAddon.py will have 'class LoadConfigAddon(IAddonInfo)'
- 1 Addon per file only!!
- Addon class should inherit from 'IAddonInfo'
- Do not use 'sys.exit(0)'!
- Always have 'start', 'execute', 'stop', '__addon__' & '__info__' functions
- You can specify your own function names with config file in your project
** NOTE: Always have '__info__' & '__addon__' to get meta information **
Meta:
- No extra file for every module, all file meta is included in addon
- use __info__ function to define addon meta ( simple dictionary )
meta = {
'uuid': '5b2dd0d5-2bbd-40a9-8250-c21167dbb822', # Not used
'name': 'FileIOAddon', # Addon name
'type': '0', # Type of addon for __future__
'description': 'File IO related operations will be done with this addon',
'execution_seq': ['start', 'execute'],
'stop_seq': ['stop'],
'version': '1.0.5',
'author': 'Ninad Mhatre',
'help_url': 'http://www.google.com/easydep/addon/FileIOAddon.html'
}
Usage
------
1. Get this module installed
2. use it in main program
3. import modules
from AddonLoader import AddonLoader as loader
from AddonLoader import AddonExecutor as runner
4. Initialize loader
# Note : will user addon-loader.info file in current project to figure out addon locations
loader_mgr = loader(verbose=True)
5. Load all addons
loader_mgr.load_addons()
6. Okay! Its time to run addons
# initialize runner with <execution> and <stop> sequence
# exection_seq - runner will execute <addon>.start() -> <addon>.execute() first
# irrespecitive of above execution result
# runner with execute <addon>.stop() when above 2 finishes!
run_mgr = runner(['start', 'execute'], ['stop'])
# get instance of required addon
7. Get instance of particular addon by its name
cli = loader_mgr.get_instance('CommandLineAddon')
8. print all addon info (__info__)
cli.print_addon_info()
9. this will run with run order specified while initializing run_manger
run_mgr.execute_with_default(cli)
fileio = loader_mgr.get_instance('FileIOAddon')
fileio.print_addon_info()
10. Specify your own run order
run_mgr.execute_with_order(fileio, ['execute', 'start'], ['stop'])
pingadd = loader_mgr.get_instance('PingAddon')
pingadd.print_addon_info()
11. Run with run order specified by addon it self...
run_mgr.execute_with_config(pingadd)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。