Yet another finite state machine with memory and callbacks.
Project description
install
pip install marmoolak
Usage
import marmoolak marmoolak.REDIS_HOST = '192.168.99.100' marmoolak.REDIS_PORT = 6379 machine = marmoolak.Machine def onpanic(e): print('panic! ' + e.msg) def oncalm(e): print('thanks to ' + e.msg + ' done by ' + e.args[0]) def ongreen(e): print('green') def onyellow(e): print('yellow') def onred(e): print('red') fsm = machine('myname', 'version1' , {'initial': 'green', 'events': [ {'name': 'warn', 'src': 'green', 'dst': 'yellow'}, {'name': 'panic', 'src': 'yellow', 'dst': 'red'}, {'name': 'panic', 'src': 'green', 'dst': 'red'}, {'name': 'calm', 'src': 'red', 'dst': 'yellow'}, {'name': 'clear', 'src': 'yellow', 'dst': 'green'}], 'callbacks': { 'onpanic': onpanic, 'oncalm': oncalm, 'ongreen': ongreen, 'onyellow': onyellow, 'onred': onred }}) fsm.panic(msg='killer bees', url="http://appido.ir/appido/api/getBooks.json") fsm.calm('bob', msg='sedatives in the honey pots')
credits
I used fysom and redis for achiving this functionality. So most of the credit goes to redis and fysom developers.
Contact me
Feel free to drop me a mail at rodmena@me.com
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for marmoolak-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4cb60140c9ddb392b3d5c0dcf13d138dbc04bc711ae2dbab2e83a4033545ec5 |
|
MD5 | 21716ba7290d421a1762efb52acf3ab8 |
|
BLAKE2b-256 | 3aa6ac3a5a6350d6407d6eb252fdfa802c1ebdb0e6c1fbaeddc4c207b89d6520 |
Close
Hashes for marmoolak-1.0.7-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef311745469c69b349d64f30b9daa72086aa9e57924466549eb12eb332e90b02 |
|
MD5 | b1d15e77e481ac1c21a5f88499ee70e5 |
|
BLAKE2b-256 | e93cae843eff1591accca78a6cd3b544f0ccf42f332ae522a1240645b6164f17 |