Yet another finite state machine with memory.
Project description
# marmoolak
Yet another finite state machine with memory
![alt logo](logo.png)
### install ###
```
pip install marmoolak
```
### Usage ###
```
from marmoolak import 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://appidi.ir/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
Yet another finite state machine with memory
![alt logo](logo.png)
### install ###
```
pip install marmoolak
```
### Usage ###
```
from marmoolak import 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://appidi.ir/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 Distribution
Close
Hashes for marmoolak-0.0.8.macosx-10.6-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6dd0eecec6b4a123335632bd6a85c57703b8d3c596aa1aa07cdef11854f4825 |
|
MD5 | d2cbb3a1b2471fb0cd03728eb4df6394 |
|
BLAKE2b-256 | d7ec80b518b0b8142b6d9bce0ddecaf5472c9ec486bff994334820b289ee78f9 |