Skip to main content

A hierarchical finite state machine library

Project description

gotstate

Security Quality Gate Status Tests Lint

A hierarchical finite state machine (HFSM) library for Python, focusing on reliability and ease of use.

Features

  • Hierarchical state machines with composite states
  • Type-safe state and event handling
  • Thread-safe event processing
  • Guard conditions and transition actions
  • State data management with lifecycle hooks
  • Timeout events
  • History states (both shallow and deep)
  • Error handling
  • Activation hooks for monitoring
  • Plugin system

Status

Version 1.0.X

Initial release!

Design Philosophy

gotstate is designed with the following principles:

  • Safety: Runtime validation and type checking
  • Clarity: Intuitive API design
  • Reliability: Built for real-world applications
  • Performance: Minimal overhead
  • Flexibility: Extensible through plugins

Example

from hsm.core import StateMachine, State, Event, Transition

# Define states
class Idle(State):
    pass

class Running(State):
    pass

# Define events
class Start(Event):
    pass

class Stop(Event):
    pass

# Create state machine
sm = StateMachine("example")
idle = sm.add_state(Idle("idle"))
running = sm.add_state(Running("running"))

# Add transitions
sm.add_transition(Transition(idle, running, Start))
sm.add_transition(Transition(running, idle, Stop))

# Initialize and use
sm.initialize()
assert sm.current_state == idle
sm.handle_event(Start())
assert sm.current_state == running

Installation

Install using pip:

pip install gotstate

Requirements

  • Python 3.8 or higher
  • See requirements.txt for full dependencies

Documentation

Documentation is available in the docs/ directory:

  • API Reference
  • Usage Guide
  • Examples

License

Licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please read our contributing guidelines in CONTRIBUTING.md.

Security

This package follows Python security best practices.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gotstate-1.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gotstate-1.0.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file gotstate-1.0.2.tar.gz.

File metadata

  • Download URL: gotstate-1.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for gotstate-1.0.2.tar.gz
Algorithm Hash digest
SHA256 36841fee4ab1f9ef8ed7f40c4bd690aba657787b73543daba344aaf57c5a8aa0
MD5 6ef376e504a93500995e6f88ac30e5fa
BLAKE2b-256 5c2d6980c6bdd910edd4e8722d2241db4873369fc18ce2d4a2bb4efe9989450a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gotstate-1.0.2.tar.gz:

Publisher: publish.yml on Brad-Edwards/gotstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gotstate-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: gotstate-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for gotstate-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 811556684a5f1f487253feee6d0dd9fd2d8c30f0c06b017f3fb57d31503d7e4c
MD5 107b0f3ddab70782f8cce434f432e26e
BLAKE2b-256 5cf4a20c66d781848258024a17225b1e64be1032b798ed6e77e89f105d6329b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gotstate-1.0.2-py3-none-any.whl:

Publisher: publish.yml on Brad-Edwards/gotstate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page