Skip to main content

Readable Runtime State Machine

https://travis-ci.org/jnmclarty/rrsm.svg?branch=master https://coveralls.io/repos/jnmclarty/rrsm/badge.svg

Enables a finite state machine to be created at run-time AND leverage simple attribute syntax creating self documenting code.

Normally these concepts are mutually exclusive, and in any finished design can hard coded. This module is handy during prototyping.

Usage

>>> from rrsm import StateMachine

>>> #Instantiation works with a list of the form ['state', ...]
... #or a dictionary of the form {'state' : value, ...}
... SM = StateMachine(['cool', 'off', 'on', 'warm'])

>>> #checking state works against strings or integers:
... SM == 'cool'
True

>>> #Change the state
... SM('warm')

>>> #using attributes to check state:
... SM == SM.cool
False
>>> SM == SM.warm
True
>>> SM.current_state
'warm'
>>> SM.current_code
3

For hardcoded finite state machines, the Super State Machine project seems like a more promising solution.

This implementation has no dependencies, nor does it import any of the standard library. It should work on any python version, but it’s tested with 2.6, 2.7, 3.3 and 2.4. Some exceptions probably apply to the exception handling. Pun intended.

Install

The easiest way to install is:

pip install rrsm

Metadata

Release files for rrsm 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rrsm 0.2.0
File Size Uploaded Provenance
rrsm-0.2.0.zip 6.7 kB Without provenance Details

Release files / rrsm-0.2.0.zip

Download URL rrsm-0.2.0.zip
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
805b59d543caeab6cc58f97143469a12790cca7d88fd3180ccd72c067703e330
BLAKE2b-256 checksum
How to use checksums
4b287f441ece7fb54571594f6cc90c7b22e46c4114c959815471a2fdcc2c7891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for rrsm 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page