This release is a pre-release and may not be stable for production use.
Superstate
Robust statechart for configurable automation rules.
How to use
A very simple example taken from specs.
>>> from superstate import StateChart
>>> class SimpleMachine(StateChart):
... state = {
... 'initial': 'created',
... 'states': [
... {
... 'name': 'created',
... 'transitions': [
... {'event': 'queue', 'target': 'waiting'},
... {'event': 'cancel', 'target': 'canceled'},
... ],
... },
... {
... 'name': 'waiting',
... 'transitions': [
... {'event': 'process', 'target': 'processed'},
... {'event': 'cancel', 'target': 'canceled'},
... ]
... },
... {'name': 'processed'},
... {'name': 'canceled'},
... ]
... }
>>> machine = SimpleMachine()
>>> machine.current_state
'AtomicState(created)'
>>> machine.trigger('queue')
>>> machine.current_state
'AtomicState(waiting)'
>>> machine.trigger('process')
>>> machine.current_state
'AtomicState(processed)'
>>> cancel_machine = SimpleMachine()
>>> cancel_machine.current_state
'AtomicState(created)'
>>> cancel_machine.trigger('cancel')
>>> cancel_machine.current_state
'AtomicState(canceled)'
States
A Superstate state machine must have one initial state and at least one other additional state.
A state may have pre and post callbacks, for running some code on state on_entry
and on_exit, respectively. These params can be method names (as strings),
callables, or lists of method names or callables.
Transitions
Transitions lead the machine from a state to another. Transitions must have
both event, and target parameters. The event is the method that have to be
called to launch the transition. The target is the state to which the
transition will move the machine. This method is automatically created
by the Superstate engine.
A transition can have optional action and cond parameters. action is a
method (or callable) that will be called when transition is launched. If
parameters are passed to the event method, they are passed to the action
method, if it accepts these parameters. cond is a method (or callable) that
is called to allow or deny the transition, depending on the result of its
execution. Both action and cond can be lists.
The same event can be in multiple transitions, going to different states, having
their respective needs as selectors. For the transitions having the same event,
only one cond should return a true value at a time.
Install
pip install superstate
Test
tox
Attribution
Superstate is forked from https://github.com/nsi-iff/fluidity created by Rodrigo Manhães.
Metadata
Release files for superstate 1.6.2a3
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 | |
|---|---|---|---|---|
| superstate-1.6.2a3.tar.gz | 26.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superstate-1.6.2a3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.6 kB
Release files / superstate-1.6.2a3.tar.gz
| Download URL | superstate-1.6.2a3.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b580de39d3e667a9bb9cf92dd14b801a2884bdfc0765eb41abfea2319a051ab
|
|
BLAKE2b-256 checksum How to use checksums |
3da68acf8a76af5d31e14df81222662a0e66328ad65acde406b07a39def8d975
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / superstate-1.6.2a3-py3-none-any.whl
| Download URL | superstate-1.6.2a3-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51aa612b2e4f92326f1430b842a9d30ae4dc797314054e2b82642bdf25f1e78e
|
|
BLAKE2b-256 checksum How to use checksums |
62f59281f79e241bb4a0b7dbda5312c2842b69b1fb9cf0b27731e05097947293
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for superstate 1.6.2a3
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.