pydio


Namepydio JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/mwiatrzyk/pydio
SummarySimple and functional dependency injection toolkit for Python
upload_time2023-05-12 11:01:46
maintainer
docs_urlNone
authorMaciej Wiatrzyk
requires_python>=3.7.2,<4
licenseMIT
keywords dependency injection di framework toolkit tool library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyPI](https://img.shields.io/pypi/v/pydio)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydio)
![PyPI - License](https://img.shields.io/pypi/l/pydio)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pydio)
[![codecov](https://codecov.io/gh/mwiatrzyk/pydio/branch/master/graph/badge.svg?token=Y6DJDSOR6M)](https://codecov.io/gh/mwiatrzyk/pydio)

# PyDio

Simple and functional dependency injection toolkit for Python.

## About

PyDio aims to be simple, yet still powerful, allowing you to feed
dependencies inside your application in a flexible way. PyDio design is based
on simple assumption, that dependency injection can be achieved using simple
**key-to-function** map, where **key** specifies **type of object** you want
to inject and **function** is a **factory** function that creates
**instances** of that type.

In PyDio, this is implemented using **providers** and **injectors**. You use
providers to configure your **key-to-function** mapping, and then you use
injectors to perform a **lookup** of a specific key and creation of the final
object.

Here's a simple example:

```python
import abc

from pydio.api import Provider, Injector

provider = Provider()

@provider.provides('greet')
def make_greet():
    return 'Hello, world!'

def main():
    injector = Injector(provider)
    greet_message = injector.inject('greet')
    print(greet_message)

if __name__ == '__main__':
    main()
```

Now you can save the snippet from above as ``example.py`` file and execute
to see the output:

```shell
$ python example.py
Hello, world!
```

## Key features

* Support for any hashable keys: class objects, strings, ints etc.
* Support for any type of object factories: function, coroutine, generator,
  asynchronous generator.
* Automatic resource management via generator-based factories
  (similar to pytest's fixtures)
* Multiple environment support: testing, development, production etc.
* Limiting created object's lifetime to user-defined scopes: global,
  application, use-case etc.
* No singletons used, so there is no global state...
* ...but you still can create global injector on your own if you need it :-)

## Installation

You can install PyDio using one of following methods:

1) From PyPI (for stable releases):

    ```shell
    $ pip install PyDio
    ```

2) From test PyPI (for stable and development releases):

    ```shell
    $ pip install -i https://test.pypi.org/simple/ PyDio
    ```

3) Directly from source code repository (for all releases):

    ```shell
    $ pip install git+https://gitlab.com/zef1r/PyDio.git@[branch-or-tag]
    ```

## Documentation

You have two options available:

1) Visit [PyDio's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.

2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).

## License

This project is released under the terms of the MIT license.

See [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.

## Author

Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mwiatrzyk/pydio",
    "name": "pydio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.2,<4",
    "maintainer_email": "",
    "keywords": "dependency,injection,di,framework,toolkit,tool,library",
    "author": "Maciej Wiatrzyk",
    "author_email": "maciej.wiatrzyk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/24/44/d0eb2f9d54d32eea446f80c471dbabfc6fb9e6b45c590ee2bbbe4abf4a54/pydio-0.4.1.tar.gz",
    "platform": null,
    "description": "![PyPI](https://img.shields.io/pypi/v/pydio)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydio)\n![PyPI - License](https://img.shields.io/pypi/l/pydio)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pydio)\n[![codecov](https://codecov.io/gh/mwiatrzyk/pydio/branch/master/graph/badge.svg?token=Y6DJDSOR6M)](https://codecov.io/gh/mwiatrzyk/pydio)\n\n# PyDio\n\nSimple and functional dependency injection toolkit for Python.\n\n## About\n\nPyDio aims to be simple, yet still powerful, allowing you to feed\ndependencies inside your application in a flexible way. PyDio design is based\non simple assumption, that dependency injection can be achieved using simple\n**key-to-function** map, where **key** specifies **type of object** you want\nto inject and **function** is a **factory** function that creates\n**instances** of that type.\n\nIn PyDio, this is implemented using **providers** and **injectors**. You use\nproviders to configure your **key-to-function** mapping, and then you use\ninjectors to perform a **lookup** of a specific key and creation of the final\nobject.\n\nHere's a simple example:\n\n```python\nimport abc\n\nfrom pydio.api import Provider, Injector\n\nprovider = Provider()\n\n@provider.provides('greet')\ndef make_greet():\n    return 'Hello, world!'\n\ndef main():\n    injector = Injector(provider)\n    greet_message = injector.inject('greet')\n    print(greet_message)\n\nif __name__ == '__main__':\n    main()\n```\n\nNow you can save the snippet from above as ``example.py`` file and execute\nto see the output:\n\n```shell\n$ python example.py\nHello, world!\n```\n\n## Key features\n\n* Support for any hashable keys: class objects, strings, ints etc.\n* Support for any type of object factories: function, coroutine, generator,\n  asynchronous generator.\n* Automatic resource management via generator-based factories\n  (similar to pytest's fixtures)\n* Multiple environment support: testing, development, production etc.\n* Limiting created object's lifetime to user-defined scopes: global,\n  application, use-case etc.\n* No singletons used, so there is no global state...\n* ...but you still can create global injector on your own if you need it :-)\n\n## Installation\n\nYou can install PyDio using one of following methods:\n\n1) From PyPI (for stable releases):\n\n    ```shell\n    $ pip install PyDio\n    ```\n\n2) From test PyPI (for stable and development releases):\n\n    ```shell\n    $ pip install -i https://test.pypi.org/simple/ PyDio\n    ```\n\n3) Directly from source code repository (for all releases):\n\n    ```shell\n    $ pip install git+https://gitlab.com/zef1r/PyDio.git@[branch-or-tag]\n    ```\n\n## Documentation\n\nYou have two options available:\n\n1) Visit [PyDio's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.\n\n2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).\n\n## License\n\nThis project is released under the terms of the MIT license.\n\nSee [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.\n\n## Author\n\nMaciej Wiatrzyk <maciej.wiatrzyk@gmail.com>\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple and functional dependency injection toolkit for Python",
    "version": "0.4.1",
    "project_urls": {
        "Documentation": "https://pydio.readthedocs.io",
        "Homepage": "https://github.com/mwiatrzyk/pydio",
        "Repository": "https://github.com/mwiatrzyk/pydio"
    },
    "split_keywords": [
        "dependency",
        "injection",
        "di",
        "framework",
        "toolkit",
        "tool",
        "library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54bd9f72b6743879b38dab8be599401396c90b354b624e5f14427634b05320c2",
                "md5": "982bb089d46f64b9837fa804d28345e1",
                "sha256": "8af3df9804feaefe6e540aebb11b5f83ca8e32eba7babf52c32a88963932df16"
            },
            "downloads": -1,
            "filename": "pydio-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "982bb089d46f64b9837fa804d28345e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.2,<4",
            "size": 14526,
            "upload_time": "2023-05-12T11:01:38",
            "upload_time_iso_8601": "2023-05-12T11:01:38.830885Z",
            "url": "https://files.pythonhosted.org/packages/54/bd/9f72b6743879b38dab8be599401396c90b354b624e5f14427634b05320c2/pydio-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2444d0eb2f9d54d32eea446f80c471dbabfc6fb9e6b45c590ee2bbbe4abf4a54",
                "md5": "5e61f47f63b3ee7e54207403c396b4b6",
                "sha256": "3034a3d3227acf121af8dedccb638baf0970dc6383a71d90e74daa7697e9a96b"
            },
            "downloads": -1,
            "filename": "pydio-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5e61f47f63b3ee7e54207403c396b4b6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.2,<4",
            "size": 11754,
            "upload_time": "2023-05-12T11:01:46",
            "upload_time_iso_8601": "2023-05-12T11:01:46.807565Z",
            "url": "https://files.pythonhosted.org/packages/24/44/d0eb2f9d54d32eea446f80c471dbabfc6fb9e6b45c590ee2bbbe4abf4a54/pydio-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-12 11:01:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mwiatrzyk",
    "github_project": "pydio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "tox": true,
    "lcname": "pydio"
}
        
Elapsed time: 0.08369s