Skip to content

Latest commit

ย 

History

History
74 lines (50 loc) ยท 1.88 KB

File metadata and controls

74 lines (50 loc) ยท 1.88 KB

madframe - Functional State-Machine Framework for Python

  • ๐Ÿ’ข TypeCheck at runtime (coming soon !)
  • โ˜ฎ๏ธ Non intruisive
  • ๐Ÿงฐ Functionnal
  • ๐Ÿ• Event-Based

โš ๏ธ 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.

from madframe.autofill import autofill

context = {"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 it

await autofill(some_function, args["bar"], context=context) # we pass an argument
> "bar"

๐Ÿ’ every madframe decorator uses autofill

๐Ÿ•™ Routine

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

from madframe.bindings import wire

something_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)`

Package test pypi python: >3.9

Installation

pip3 install madframe