Minimata is a minimalist state-machine implementation.
Project description
Minimata: minimalist state-machine in Python
Miniata is a very small library to manage state-machines in Python.
Because it doesn't bundle a lot of features, it's pretty flexible.
Installation
Use the package manager pip to install minimata.
pip install minimata
Why
I needed a really simple implementations and didn't wanted to reach to heavier alternatives like transitions.
Usage
Here is an example:
from minimata import StateMachine, skip_transition
model_onboarding_state_machine = StateMachine("onboarding_state")
@model_onboarding_state_machine.on("event", {"source_state": "destination_state"})
def callback(model: Model, param: bool = False, **kwargs):
if param:
print(model)
@dataclass
class UserModel:
onboarding_state: str
user_model = UserModel(onboarding_state="source_state")
model_onboarding_state_machine.trigger(
model=user_model,
event="event",
param=True,
) # Executes callback (prints user_model) *THEN* update its state.
Contributing
With a hundred line of code, it's possible to get there and customize this. It'll probably make sense for you to copy-paste that code rather than to add it as a dependency.
That being said, pull-requests are welcome. It would be nice to polish the library, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Credits
Inspiration was heavily taken from the following projects.
Many thanks to their authors, maintainers, and contributors.
License
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
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
File details
Details for the file minimata-0.1.1.tar.gz.
File metadata
- Download URL: minimata-0.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdd063c7d1696402d2fdba253eeb8cc672040d381be2118dfa79c553289ed90a
|
|
| MD5 |
c6b6618802f33a20286e4fef61b85eb9
|
|
| BLAKE2b-256 |
41933692a6ecd6e6537f6ad6ca1fac3f64eda2275ec174b85651572f747fa63d
|
File details
Details for the file minimata-0.1.1-py3-none-any.whl.
File metadata
- Download URL: minimata-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8faa2bad1e3fe63c4930eaa680b7b70b05f2e5ae49f405b8b1d410a80c1cff1e
|
|
| MD5 |
63145d0ef324622abc075eebf8b9c83b
|
|
| BLAKE2b-256 |
58961a011736cc34c0e62ae19416be4213f4bf91a8f23c3c2a84d17723505841
|