Python State-Machine library
Project description
Easy State-Machine for python
from easystate import * import time SPEED = 1
- class Starting(State):
- def eval(self):
print ‘Starting’ time.sleep(SPEED)
- def on_start(self,e):
print “Hello”
- def on_finish(self,e):
self.transition(“Listening”)
class Listening(State):
- def eval(self):
print ‘Listening’ time.sleep(SPEED) self.raiseEvent(“connect”)
- def on_start(self,e):
print “Preparing for listening”
- def on_connect(self,e):
self.transition(‘Negotiation’)
- class Negotiation(State):
- def eval(self):
print ‘checking validity’ time.sleep(SPEED) print ‘authenticating’ time.sleep(SPEED) print ‘registering’ self.transition(“Connected”)
- def on_start(self,e):
print ‘Negotiating’
- class Connected(State):
- def eval(self):
print ‘Connected’
- def on_finish(self,e):
self.transition(“Listening”)
m = StateMachine(initialState=”Starting”) m.appendState(Starting()) m.appendState(Listening()) m.appendState(Negotiation()) m.appendState(Connected()) m.start()
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
Built Distribution
File details
Details for the file easystate-0.3.tar.gz
.
File metadata
- Download URL: easystate-0.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 179bea5419370329d005c3983dca22c80d84581d85924f54265b5a05a22f6f7b |
|
MD5 | 2b6047fc154bbd51c8f07d6828c80311 |
|
BLAKE2b-256 | 8f256ca78f73f596abcd857dfe6ad7d003b8c7f99cf11d01fad30f5a94aa3d65 |
File details
Details for the file easystate-0.3-py2.7.egg
.
File metadata
- Download URL: easystate-0.3-py2.7.egg
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 984f18f712fe6937eeb13ab3cda115c1114a4f8dc4c7c9c10b75414a39344996 |
|
MD5 | 6de3f581c1de0c3022a0f1db16c4606c |
|
BLAKE2b-256 | dda4b9e48408d28ecc132e72ad82ccccd88ede362e3846d972b6ace14af5f4b9 |