GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - statelyai/xstate-python: XState for Python

BranchesTags
Open more actions menu

Latest commit

 

History

116 Commits
116 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
examples
examples
 
 
test-framework @ b46a10a
test-framework @ b46a10a
 
 
tests
tests
 
 
xstate
xstate
 
 
.flake8
.flake8
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
poetry.lock
poetry.lock
 
 
poetry.toml
poetry.toml
 
 
pyproject.toml
pyproject.toml
 
 
viz.py
viz.py
 
 

Repository files navigation

XState for Python

XState for Python - work in progress!

How to use

from xstate 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

Developing

You can set up your development environment in two different ways.

Using Remote Containers (recommended if you use VS Code)

Prerequisites

  • VS Code IDE and Remote Containers extension

Steps

  1. Open the folder in a container. This will setup your environment with python (including python and pylance extensions), dependencies and download scxml tests.
  2. Run poetry run pytest --cov to run the tests! 👩‍🔬 (or run the Run tests task via VS Code or using VS Code Test explorer where you can debug as well)

Or installing the environment on your local drive

Prerequisites

  • poetry for package and dependency management

Steps

  1. Run poetry install to create a virtual environment
  2. Make sure test files are present and up to date by running git submodule update --init
  3. Run poetry run pytest --cov to run the tests! 👩‍🔬 (or run the Run tests task via VS Code or using VS Code Test explorer where you can debug as well)

SCXML

SCXML tests are ran from the SCION Test Framework module.

Related Projects

  • finite-state-machine
  • Sismic for Python
  • Miros
  • Automat

About

XState for Python

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

199 stars

Watchers

7 watching

Forks

18 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.