A hierarchical finite state machine library
Project description
gotstate
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
Features:
- Full test coverage
- Type hints
- Input validation
- Error handling
- API documentation
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.txtfor 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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gotstate-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gotstate-1.0.0-py3-none-any.whl
- Upload date:
- Size: 34.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f672243c7e4f30883d127aac0060fedb2c7446b27f8d921cff89fff41d780a86
|
|
| MD5 |
4f0aec7c72708849fe767690148b804f
|
|
| BLAKE2b-256 |
f7b325d44b7272d6187577cbdfdd1a7d1cf16bde8c7d1b0e61d4d9360831106f
|