A robust event handling framework for Python
Project description
🌟 Prasar Event Handling Framework 🌟
🚀 Robust, Type-Safe, and Asynchronous Event Handling for Python 🐍
✨ Features
- 🔄 Support for both synchronous and asynchronous events
- 🛡️ Strong type checking for event arguments and return types
- 🌈 Custom logging with colored output
- 🎛️ Easy-to-use API for binding and emitting events
- 🧪 Comprehensive error handling and validation
🛠️ Installation
To install Prasar, simply use pip:
pip install prasar
📚 Dependencies
- Python 3.7+
- colorama
- typing
🚀 Quick Start
from prasar import Prasar
# Create a Prasar instance
prasar = Prasar()
# Define and bind a synchronous event
def greet(name: str) -> str:
return f"Hello, {name}!"
prasar.bind_event("greet", greet, str, return_type=str)
# Emit the event
result = prasar.emit("greet", "Alice")
print(result) # Output: Hello, Alice!
# Define and bind an asynchronous event
async def fetch_data(url: str) -> dict:
# Simulating async operation
return {"data": "Some data from " + url}
prasar.bind_async_event("fetch", fetch_data, str, return_type=dict)
# Emit the async event
import asyncio
result = asyncio.run(prasar.async_emit("fetch", "https://example.com"))
print(result) # Output: {'data': 'Some data from https://example.com'}
🌈 Logging
Prasar includes a custom logging module with colorful output:
from prasar_logger import Logger
logger = Logger("MyLogger").get_logger()
logger.info("✅ This is an info message")
logger.error("❌ This is an error message")
📘 API Reference
Prasar Class
| Method | Description |
|---|---|
| bind_event() | Binds a synchronous event |
| bind_async_event() | Binds an asynchronous event |
| emit() | Emits a synchronous event |
| async_emit() | Emits an asynchronous event |
Logger Class
| Method | Description |
|---|---|
| init() | Initializes a new Logger instance |
| get_logger() | Returns the configured logger object |
For detailed API documentation, please visit our API Reference.
🤝 Contributing
We welcome contributions! Please see our Contribution Guidelines for more details.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
🙏 Acknowledgements
- Thanks to all our contributors and users!
- Inspired by various event handling systems in the Python ecosystem.
⭐ Star us on GitHub | 🐦 Follow us on Instagram
Project details
Release history Release notifications | RSS feed
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 prasar-1.2.1.tar.gz.
File metadata
- Download URL: prasar-1.2.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f36ce251e1ec3ee969d0b00e8b08d73ba80fd869c6827a0f845a46a8698bfd1e
|
|
| MD5 |
29c3015dc038e163fbb34ea4d6674f8c
|
|
| BLAKE2b-256 |
126d92eab6eb61a891a5979cc348f3b52b1ada5cbdf3e178b5e8d72f4a556528
|
File details
Details for the file Prasar-1.2.1-py3-none-any.whl.
File metadata
- Download URL: Prasar-1.2.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed7f2380612d3339aa7074a54fbe19871c9bca5d7599deeff65fd1c81e7748e
|
|
| MD5 |
2ecc7e34d48a26bcf89d9e5fa5fc223d
|
|
| BLAKE2b-256 |
a6efc7f5ddee2f9401bd4d6f2ae389cc7296fd3e391c0296da89916535a25cd9
|