Skip to main content

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

MIT

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

minimata-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minimata-0.1.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

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

Hashes for minimata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bdd063c7d1696402d2fdba253eeb8cc672040d381be2118dfa79c553289ed90a
MD5 c6b6618802f33a20286e4fef61b85eb9
BLAKE2b-256 41933692a6ecd6e6537f6ad6ca1fac3f64eda2275ec174b85651572f747fa63d

See more details on using hashes here.

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

Hashes for minimata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8faa2bad1e3fe63c4930eaa680b7b70b05f2e5ae49f405b8b1d410a80c1cff1e
MD5 63145d0ef324622abc075eebf8b9c83b
BLAKE2b-256 58961a011736cc34c0e62ae19416be4213f4bf91a8f23c3c2a84d17723505841

See more details on using hashes here.

Supported by

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