Yet another finite state automaton for python.
Introduction
The emphasis is on a simple, readable configuration:
automata1:
start: Occupied
states:
Occupied: {}
Alarmed: {}
transitions:
Occupied->Alarmed:
when: house.presence.empty
Occupied->Alarmed:
when: house.presence.occupied
It’s particularly suited to home automation (my use case).
Example
For an example of using finite for home automation, see: test/test1.dfa.
Configuration
The configuration format is yaml.
Each automata has a start state, a set of states and a set of transitions:
automata1:
start: Occupied
states:
Occupied:
{}
Alarmed:
{}
transitions:
Occupied->Alarmed:
when: house.presence.empty
Occupied->Alarmed:
when: house.presence.occupied
Transitions may have actions associated with them:
Occupied->Alarmed:
when: house.presence.empty
actions:
- speak('Alarm activated')
These callbacks are called on the ‘callback’ object passed when make_world.
A yaml file may list multiple automaton:
automata1:
start: State1
states: ...
transitions: ...
automata2:
start: State2
states: ...
transitions: ...
Code
Example:
from finite import dfa
# create a callback
class Callback(object):
def speak(self, msg):
# do some speaking
pass
callback = Callback()
# create automaton
worlds = dfa.Worlds()
automatons = dfa.Loader.load_file('my.dfa')
for aut in automatons:
world = aut.make_world(callback)
self.worlds.add(world)
# trigger a state change
ev = dfa.Event('house.presence.empty', True)
worlds.process(ev)
Changelog
0.1.0
First release
Metadata
Release files for finite 0.1.0
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 |
|---|---|---|---|---|
| finite-0.1.0.tar.gz | 6.8 kB | Without provenance | Details for finite-0.1.0.tar.gz |
Release files / finite-0.1.0.tar.gz
| Download URL | finite-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb1ca4ba0570cb641009e17468615a92040e24f5ed8132204c26bbae658ee0e0
|
|
BLAKE2b-256 checksum How to use checksums |
eac95824c2cb1bcee08caf6b44ea4fb2a9d23df63eb5481ad7961c2e5832d054
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for finite 0.1.0
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.