XState for Python
XState for Python - work in progress!
How to use
from xstate.machine import Machine
lights = Machine(
{
"id": "lights",
"initial": "green",
"states": {
"green": {"on": {"TIMER": "yellow"},},
"yellow": {"on": {"TIMER": "red"}},
"red": {"on": {"TIMER": "green"}},
},
}
)
state = lights.initial_state # state.value is green
state = lights.transition(state, "TIMER") # state.value is yellow
state = lights.transition(state, "TIMER") # state.value is red
state = lights.transition(state, "TIMER") # state.value is green again
More advanced examples in the "examples" folder
Testing
- Run
python3.7 -m venv .venvto create a virtual environment - Run
source .venv/bin/activateto go into that virtual environment - Run
pip install -r requirements_dev.txtto install all of the dependencies inrequirements.txt(which includespytest) - Run
npm i @scion-scxml/test-frameworkto download scxml files - Run
pytestto run the tests! 👩🔬
SCXML
SCXML tests are ran from the SCION Test Framework module.
Related Projects
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xstate-0.0.1.tar.gz
(9.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
xstate-0.0.1-py2-none-any.whl
(12.4 kB
view details)
File details
Details for the file xstate-0.0.1.tar.gz.
File metadata
- Download URL: xstate-0.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e17a78934a8c9ea0c823891d0194f58a59cfd273f8ced0293f45c89f214a8494
|
|
| MD5 |
06fef8f504614ee85bbc0d0aa6176b57
|
|
| BLAKE2b-256 |
830c36a48f52f7344677fd176f65a5599e39eec0ea50163c5376327ff889bf32
|
File details
Details for the file xstate-0.0.1-py2-none-any.whl.
File metadata
- Download URL: xstate-0.0.1-py2-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
568f3d38634f03966a0121c0c98ed79d38ffd2e10b4f9c7be91e3cd369fcc500
|
|
| MD5 |
7f2b8ad0afe31d52691b26e5d4a6c50f
|
|
| BLAKE2b-256 |
cd7ff2b32f2aec21c1f317ca53ffe657ff2ddb33ab3f02fd02ebb5087e3815ef
|