Metadata-Version: 2.1
Name: statez
Version: 0.1.1
Summary: Helps you to build fancy statemachines
License: GPL-3
Author: 4thel00z
Author-email: 4thel00z@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown

# statez

![statez.png](https://raw.githubusercontent.com/4thel00z/logos/master/statez.png)

## Motivation

All the statemachine packages for python look weird and do too much stuff.
This one is simple (and synchronous).


## Installation

```
pip install statez

# or if you use poetry
poetry add statez
```

## Usage

```python
from statez.core import (
    Trigger,
    From,
    To,
    Do,
    StateMachine,
    Event
)

if __name__ == '__main__':
    s = StateMachine("HungryBoi", state="hungry")
    transition = Trigger("Eat") | From(["hungry", "dunno"]) | To("not_hungry") | Do(lambda a: True)
    # It doesn't matter if you use the function directly or if you wrap it in Do :-)
    assert transition == Trigger("Eat") | From(["hungry", "dunno"]) | To("not_hungry") | (lambda a: True)
    s += transition
    s.consume(Event("Eat"))
    assert s.state == "not_hungry", s.state
```

## License

This project is licensed under the GPL-3 license.

