https://github.com/6r17/madframe
Customizable Asynchronous State-Machine
https://github.com/6r17/madframe
asyncio events framework functionnal python3
Last synced: 3 months ago
JSON representation
Customizable Asynchronous State-Machine
- Host: GitHub
- URL: https://github.com/6r17/madframe
- Owner: 6r17
- Created: 2023-05-27T15:14:38.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-27T19:39:23.000Z (about 2 years ago)
- Last Synced: 2025-02-14T20:46:15.532Z (4 months ago)
- Topics: asyncio, events, framework, functionnal, python3
- Language: Python
- Homepage:
- Size: 1.07 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**madframe** - Functional State-Machine Framework for Python
- ~💢 TypeCheck at runtime~ (coming soon !)
- ☮️ Non intruisive
- 🧰 Functionnal
- 🕐 Event-Based:warning: This project is in Alpha state.
## Includes
### 🤖 Autofill
Autofill is the process of automaticaly composing a function usage deduced from the prototype naming and a given context.
```python
from madframe.autofill import autofillcontext = {"value": "foo"}
def some_function(value):
print(value)await autofill(some_function, args=[], context=context) # notice that we don't pass any argument
> "foo"
# autofill undertand it has to retrieve the value from context if you don't specify itawait autofill(some_function, args["bar"], context=context) # we pass an argument
> "bar"
```
💁 **every madframe decorator uses `autofill`**
### 🕙 Routine
```python
from madframe.bindings import setup@setup
def initialize():
return {"some_key": "foo"}@routine(1)
def print_foo(some_key):
print(some_key) # -> prints "foo"
```### 🏗️ Setup
Setup is used to define function to be ran at start-up. Those executions block the start-up and will abort the lauch if they fail.
### 📝 Perpetuate
`perpetuate` is `autofill` but the context is also updated with the result of the function (given it's a `dict`)
### 🚩 Wire
```python
from madframe.bindings import wiresomething_is_done_when, do_something_when = wire()
fetch = do_something_when(fetch_data)
something_is_done_when(analyze_data)fetch # is equivalent of `analyze_data(fetch_data)`
```[](https://github.com/6r17/madframe/actions/workflows/test.yml)
[](https://pypi.org/project/madframe/)
### Installation
```bash
pip3 install madframe
```