Skip to main content

A robust event handling framework for Python

Project description

🌟 Prasar Event Handling Framework 🌟

Prasar Logo

PyPI version License: MIT Python Versions

🚀 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.
Made with ❤️ by Abhishek Mishra

⭐ Star us on GitHub | 🐦 Follow us on Instagram

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

prasar-1.2.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

Prasar-1.2.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

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

Hashes for prasar-1.2.1.tar.gz
Algorithm Hash digest
SHA256 f36ce251e1ec3ee969d0b00e8b08d73ba80fd869c6827a0f845a46a8698bfd1e
MD5 29c3015dc038e163fbb34ea4d6674f8c
BLAKE2b-256 126d92eab6eb61a891a5979cc348f3b52b1ada5cbdf3e178b5e8d72f4a556528

See more details on using hashes here.

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

Hashes for Prasar-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed7f2380612d3339aa7074a54fbe19871c9bca5d7599deeff65fd1c81e7748e
MD5 2ecc7e34d48a26bcf89d9e5fa5fc223d
BLAKE2b-256 a6efc7f5ddee2f9401bd4d6f2ae389cc7296fd3e391c0296da89916535a25cd9

See more details on using hashes here.

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