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
Metadata
Release files for minimata 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| minimata-0.1.1.tar.gz | 4.9 kB | Without provenance | Details for minimata-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| minimata-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for minimata-0.1.1-py3-none-any.whl |
Total release size: 12.0 kB
Release files / minimata-0.1.1.tar.gz
| Download URL | minimata-0.1.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdd063c7d1696402d2fdba253eeb8cc672040d381be2118dfa79c553289ed90a
|
|
BLAKE2b-256 checksum How to use checksums |
41933692a6ecd6e6537f6ad6ca1fac3f64eda2275ec174b85651572f747fa63d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic
|
Release files / minimata-0.1.1-py3-none-any.whl
| Download URL | minimata-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8faa2bad1e3fe63c4930eaa680b7b70b05f2e5ae49f405b8b1d410a80c1cff1e
|
|
BLAKE2b-256 checksum How to use checksums |
58961a011736cc34c0e62ae19416be4213f4bf91a8f23c3c2a84d17723505841
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic
|
Security for minimata 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.