mediatpy


Namemediatpy JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/panicoenlaxbox/mediatpy
SummaryMediator implementation in Python
upload_time2022-12-10 16:11:48
maintainer
docs_urlNone
authorSergio León
requires_python>=3.10,<4.0
license
keywords mediator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
![Upload Python Package](https://github.com/panicoenlaxbox/mediatpy/actions/workflows/python-publish.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/panicoenlaxbox/mediatpy/badge.svg?branch=main)](https://coveralls.io/github/panicoenlaxbox/mediatpy?branch=main)
[![Documentation Status](https://readthedocs.org/projects/mediatpy/badge/?version=latest)](https://mediatpy.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/mediatpy.svg)](https://badge.fury.io/py/mediatpy)

# Introduction

This library is a port of [Mediatr](https://github.com/jbogard/MediatR) in Python.

For more information and usage instructions, see the [documentation](https://mediatpy.readthedocs.io/en/latest/).

# Usage

`pip install mediatpy`

```python
import asyncio

from mediatpy import Request, RequestHandler, Mediator


class MyResponse:
    pass


class MyRequest(Request[MyResponse]):
    pass


mediator = Mediator()


@mediator.request_handler
class MyRequestHandler(RequestHandler[MyRequest, MyResponse]):
    async def handle(self, request: MyRequest) -> MyResponse:
        return MyResponse()


async def main():
    request = MyRequest()
    response = await mediator.send(request)
    assert isinstance(response, MyResponse)


if __name__ == '__main__':
    asyncio.run(main())
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/panicoenlaxbox/mediatpy",
    "name": "mediatpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "mediator",
    "author": "Sergio Le\u00f3n",
    "author_email": "panicoenlaxbox@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e2/7f/c0b1c19ac3f53b5f897e5f8176679ec12ba0ba518531bf1e0cf98068ac42/mediatpy-0.2.1.tar.gz",
    "platform": null,
    "description": "[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n![Upload Python Package](https://github.com/panicoenlaxbox/mediatpy/actions/workflows/python-publish.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/panicoenlaxbox/mediatpy/badge.svg?branch=main)](https://coveralls.io/github/panicoenlaxbox/mediatpy?branch=main)\n[![Documentation Status](https://readthedocs.org/projects/mediatpy/badge/?version=latest)](https://mediatpy.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/mediatpy.svg)](https://badge.fury.io/py/mediatpy)\n\n# Introduction\n\nThis library is a port of [Mediatr](https://github.com/jbogard/MediatR) in Python.\n\nFor more information and usage instructions, see the [documentation](https://mediatpy.readthedocs.io/en/latest/).\n\n# Usage\n\n`pip install mediatpy`\n\n```python\nimport asyncio\n\nfrom mediatpy import Request, RequestHandler, Mediator\n\n\nclass MyResponse:\n    pass\n\n\nclass MyRequest(Request[MyResponse]):\n    pass\n\n\nmediator = Mediator()\n\n\n@mediator.request_handler\nclass MyRequestHandler(RequestHandler[MyRequest, MyResponse]):\n    async def handle(self, request: MyRequest) -> MyResponse:\n        return MyResponse()\n\n\nasync def main():\n    request = MyRequest()\n    response = await mediator.send(request)\n    assert isinstance(response, MyResponse)\n\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "Mediator implementation in Python",
    "version": "0.2.1",
    "split_keywords": [
        "mediator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "8f37ac51f98cb1af32474199b45a9cd5",
                "sha256": "7e88a8d04d77f49dc2839963b9cadad8868837fdad1bb547639cb54fffac41bc"
            },
            "downloads": -1,
            "filename": "mediatpy-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f37ac51f98cb1af32474199b45a9cd5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 4340,
            "upload_time": "2022-12-10T16:11:46",
            "upload_time_iso_8601": "2022-12-10T16:11:46.140674Z",
            "url": "https://files.pythonhosted.org/packages/06/9e/679605a76a0fcf769b37ef1774f620cce0b650d50bea907097ba2e6e11ad/mediatpy-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "8e05e97e2a19c5c0b8beb5b233958de8",
                "sha256": "f926643849abcac54b07dc8f33c95a4d41fcd705aec80d6d11c70325ddf9d4c7"
            },
            "downloads": -1,
            "filename": "mediatpy-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8e05e97e2a19c5c0b8beb5b233958de8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 4690,
            "upload_time": "2022-12-10T16:11:48",
            "upload_time_iso_8601": "2022-12-10T16:11:48.471948Z",
            "url": "https://files.pythonhosted.org/packages/e2/7f/c0b1c19ac3f53b5f897e5f8176679ec12ba0ba518531bf1e0cf98068ac42/mediatpy-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-10 16:11:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "panicoenlaxbox",
    "github_project": "mediatpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mediatpy"
}
        
Elapsed time: 0.01707s