66 lines
1.6 KiB
Markdown
66 lines
1.6 KiB
Markdown
# pyappengine
|
|
|
|
A Python framework for building **modular, command-based applications** with dynamic module loading, thread-safe command dispatch, and structured lifecycle management.
|
|
|
|
## Features
|
|
|
|
- **Dynamic module loading** — drop a `cmds_*.py` file in your module directory, it's loaded automatically
|
|
- **Thread-safe command dispatch** — shared lock across all modules
|
|
- **Threaded modules** — opt-in background thread execution per module
|
|
- **Inter-module dependencies** — declarative dependency injection between modules
|
|
- **Built-in help system** — introspects docstrings at runtime
|
|
- **INI configuration** — per-module config sections
|
|
- **Graceful shutdown** — SIGINT handler + global stop event
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
pip install pyappengine
|
|
```
|
|
|
|
## Quick start
|
|
|
|
**1. Create your application entry point:**
|
|
|
|
```python
|
|
from appengine import AppEngine
|
|
|
|
app = AppEngine(
|
|
"my_app",
|
|
conf_file="config.ini",
|
|
log_file="my_app.log",
|
|
debug=True,
|
|
)
|
|
app.exec(modpath="./modules")
|
|
```
|
|
|
|
**2. Create a module** — save as `modules/cmds_hello.py`:
|
|
|
|
```python
|
|
from appengine import Commands
|
|
|
|
class Hello(Commands):
|
|
def cmd_greet(self, name: str):
|
|
"""Greet someone.
|
|
|
|
Args:
|
|
name: The person to greet.
|
|
|
|
Returns:
|
|
str: A greeting string.
|
|
"""
|
|
return f"Hello, {name}!"
|
|
```
|
|
|
|
**3. Create a minimal config** — `config.ini`:
|
|
|
|
```ini
|
|
[general]
|
|
default = hello
|
|
```
|
|
|
|
## License
|
|
|
|
Released under the [CeCILL-C](https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) license.
|
|
Author: François Dausseur — fdausseur@free.fr
|