A library for state management with colored messages
Project description
StateLogic
StateLogic is a Python library for finite state machine with colored messages in the terminal.
Installation
You can install the package using pip3:
pip3 install statelogic
Usage
Here’s a basic example of how to use StateLogic:
from statelogic import StateLogic
# Create an instance of StateLogic
state_logic = StateLogic()
Using it as Finite State Machine
>>> from statelogic import StateLogic
>>> s=StateLogic()
>>> s.transition("freeze","LIQUID","SOLID")
<statelogic.StateLogic object at 0x103188950>
>>> s.transition("melts","SOLID","LIQUID")
<statelogic.StateLogic object at 0x103188950>
>>> s.state("anything else")
<statelogic.StateLogic object at 0x103188950>
>>> s.state()
>>> s.state("SOLID")
<statelogic.StateLogic object at 0x103188950>
>>> s.state()
'SOLID'
>>> s.states()
['LIQUID', 'SOLID']
>>> s.transitions()
['freeze', 'melts']
Using the Attr Class
from statelogic import Attr
class MyClass:
def __init__(self):
self.name = Attr(self, attrName="name", value="Default Name")
my_instance = MyClass()
print(my_instance.name()) # Output: Default Name
# Update the name
my_instance.name("New Name")
print(my_instance.name()) # Output: New Name
Use the critical message method
state_logic.criticalMsg("This is a critical message", tag="ERROR")
Features
- Colorful terminal messages
- Easy to use for state management
- Customizable message formatting
- Dynamic attribute management with Attr
- State transition definitions with Transition
- Reflection capabilities with Reflection
- Finite state machine functionality with FSM
- Application data management with AppData
- Signal handling with Signal
- Shell command and environment utilities with Sh
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
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 statelogic-1.0.1.tar.gz.
File metadata
- Download URL: statelogic-1.0.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a3d610d707404dd6c525ab0c50b21a8200933efa91cd8d1ce8f6e7114eb9321
|
|
| MD5 |
b055ed6d8fdf7c7b0dc59cae44934a2b
|
|
| BLAKE2b-256 |
eb7213acf59019a8c91b4f3554e4e9d5691febcc26c3a49561befb1cf82f7c76
|
File details
Details for the file statelogic-1.0.1-py3-none-any.whl.
File metadata
- Download URL: statelogic-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
266d77b8412efd41349945da8d3b83672a369d804f92029f9a57ed9c81c3a52e
|
|
| MD5 |
64df6c89f467b1ecbd99f177c22213db
|
|
| BLAKE2b-256 |
44ab8eae10599ab811e9061d6ce2ce84269d60df7ed98a89363aed2622e8e2c3
|