Small research-oriented hook-based plugin engine.
Project description
MiniFlask
Miniflask is a small research-oriented plugin-engine for python.
A long time ago in a galaxy full of plugin-engines ...
Quick Start
For a quick look into miniflask, just install it using
pip install miniflask
Read the Documentation
Short Example
Module Definition
Let's start a new project first by creating a new directory:
> ls
main.py
modules/
module1/__init__.py
module2/__init__.py
module1/__init__.py
Let's define a simple module, modules/module1/__init__.py
:
def main(state, event):
print("main event called by module1")
def register(mf):
mf.register_event('main', main, unique=False)
Let's define another module, modules/module2/__init__.py
:
def main(state, event):
print("main event called by module2")
print("it uses a variable var:", state["var"])
def register(mf):
mf.register_defaults({
"var": 42
})
mf.register_event('main', main, unique=False)
Our main.py looks like this:
import miniflask
# initialize miniflask
mf = miniflask.init(".modules")
mf.run()
Usage:
Now, we can use our program in the following ways:
> python main.py
There is nothing to do.
> python main.py module1
main event called by module1
> python main.py module2,module1
main event called by module2
it uses a variable var: 42
main event called by module1
> python main.py module2,module1 --module2.var 9001
main event called by module2
it uses a variable var: 9001
main event called by module1
Contributing
- Fork it!
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
License
- See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
miniflask-5.1.2.tar.gz
(43.0 kB
view details)
File details
Details for the file miniflask-5.1.2.tar.gz
.
File metadata
- Download URL: miniflask-5.1.2.tar.gz
- Upload date:
- Size: 43.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55b5af32d9aef6617289987651e650219f051ff53a441262871f959a6d24016b |
|
MD5 | b6dce2ee9e33137cd02b874db6488f30 |
|
BLAKE2b-256 | 5f560cbf2d457dea42a475d4864197a3694e9a64f7d4b67038b0dae93f5f9c8c |