Skip to main content

Tilakone

Super simple state machine

from tilakone import StateChart, StateMachine
from typing import Literal

States = Literal["ON", "OFF"]
Events = Literal["toggle", "turn_off"]

state_chart = StateChart[States, Events]({
    "OFF": {
        "initial": True,
        "on": {
            "toggle": "ON"
        }
    },
    "ON": {
        "initial": False,
        "on": {
            "toggle": "OFF",
            "turn_off": "OFF"
        }
    }
})

machine = StateMachine(state_chart)
assert machine.current_state == "OFF"

transitioned = machine.send("toggle")
assert transitioned == True
assert machine.current_state == "ON"

transitioned = machine.send("turn_off")
assert transitioned == True
assert machine.current_state == "OFF"

# Irrelevant events are ignored
transitioned = machine.send("turn_off")
assert transitioned == False
assert machine.current_state == "OFF"

Metadata

Release files for tilakone 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tilakone 0.1.0
File Size Uploaded
tilakone-0.1.0.tar.gz 1.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tilakone 0.1.0
File Interpreter ABI Platform
tilakone-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.8 kB

Release files / tilakone-0.1.0.tar.gz

Download URL tilakone-0.1.0.tar.gz
Size 1.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0f7b6e83583bbf56895153314f00beebf23d5fd94d8bbac622369e4544067cbe
BLAKE2b-256 checksum
How to use checksums
0b927fe6819631c95679cb0aab6a1e3d9db80fcf292b7c7db3817e00f24b1510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 FreeBSD/14.1-RELEASE-p3

Release files / tilakone-0.1.0-py3-none-any.whl

Download URL tilakone-0.1.0-py3-none-any.whl
Size 2.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc225bc5c3231a28356970e1a98da74736dc6be0f6a085b7efdf938ea0f5fbe3
BLAKE2b-256 checksum
How to use checksums
5cbd37e23f468c9baf4e6341c1122d895104e7b31f72b69eb4e7775ee2e1e38b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.9 FreeBSD/14.1-RELEASE-p3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page