Skip to main content

XState for Python

Project description

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

  1. Run python3.7 -m venv .venv to create a virtual environment
  2. Run source .venv/bin/activate to go into that virtual environment
  3. Run pip install -r requirements_dev.txt to install all of the dependencies in requirements.txt (which includes pytest)
  4. Run npm i @scion-scxml/test-framework to download scxml files
  5. Run pytest to run the tests! 👩‍🔬

SCXML

SCXML tests are ran from the SCION Test Framework module.

Related Projects

Project details


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)

Uploaded Source

Built Distribution

xstate-0.0.1-py2-none-any.whl (12.4 kB view details)

Uploaded Python 2

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

Hashes for xstate-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e17a78934a8c9ea0c823891d0194f58a59cfd273f8ced0293f45c89f214a8494
MD5 06fef8f504614ee85bbc0d0aa6176b57
BLAKE2b-256 830c36a48f52f7344677fd176f65a5599e39eec0ea50163c5376327ff889bf32

See more details on using hashes here.

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

Hashes for xstate-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 568f3d38634f03966a0121c0c98ed79d38ffd2e10b4f9c7be91e3cd369fcc500
MD5 7f2b8ad0afe31d52691b26e5d4a6c50f
BLAKE2b-256 cd7ff2b32f2aec21c1f317ca53ffe657ff2ddb33ab3f02fd02ebb5087e3815ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page