PyDIO 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyDIO
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Lightweight and functional dependency injection library for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/mwiatrzyk/pydio
|
|
6
|
+
Project-URL: Repository, https://github.com/mwiatrzyk/pydio
|
|
7
|
+
Project-URL: Documentation, https://pydio.readthedocs.io
|
|
8
|
+
Author-email: Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: dependency,di,framework,injection,library,tool,toolkit
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Requires-Dist: typing-extensions>=4.16.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+

|
|
22
|
+

|
|
23
|
+

|
|
24
|
+
[](https://codecov.io/gh/mwiatrzyk/pydio)
|
|
25
|
+
|
|
26
|
+
# PyDIO
|
|
27
|
+
|
|
28
|
+
Lightweight and functional dependency injection library for Python.
|
|
29
|
+
|
|
30
|
+
## Name
|
|
31
|
+
|
|
32
|
+
**PyDIO** (stylized as *PyDIO*, installable as `pydio`, pronounced
|
|
33
|
+
*"pie-dee-o"*) stands for **Python dependency injection library**.
|
|
34
|
+
|
|
35
|
+
## About
|
|
36
|
+
|
|
37
|
+
PyDIO aims to be simple, yet still powerful, allowing you to feed dependencies
|
|
38
|
+
inside your application in a flexible way. PyDIO design is based on simple
|
|
39
|
+
assumption that dependency injection can be achieved using a straightforward
|
|
40
|
+
**key-to-function** mapping, where **key** specifies **type of object** you
|
|
41
|
+
want to inject and **function** is a **factory** function that creates
|
|
42
|
+
**instances** of that type.
|
|
43
|
+
|
|
44
|
+
In PyDIO, this is implemented using **providers** and **injectors**. You use
|
|
45
|
+
providers to configure your **key-to-function** mapping, and then you use
|
|
46
|
+
injectors to perform a **lookup** of a specific key and creation of the final
|
|
47
|
+
object.
|
|
48
|
+
|
|
49
|
+
Here's a simple example:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import abc
|
|
53
|
+
|
|
54
|
+
from pydio.api import Provider, Injector
|
|
55
|
+
|
|
56
|
+
provider = Provider()
|
|
57
|
+
|
|
58
|
+
@provider.provides('greet')
|
|
59
|
+
def make_greet():
|
|
60
|
+
return 'Hello, world!'
|
|
61
|
+
|
|
62
|
+
def main():
|
|
63
|
+
injector = Injector(provider)
|
|
64
|
+
greet_message = injector.inject('greet')
|
|
65
|
+
print(greet_message)
|
|
66
|
+
|
|
67
|
+
if __name__ == '__main__':
|
|
68
|
+
main()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Now you can save the snippet from above as ``example.py`` file and execute
|
|
72
|
+
to see the output:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
$ python example.py
|
|
76
|
+
Hello, world!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Key features
|
|
80
|
+
|
|
81
|
+
* Support for any hashable keys: class objects, strings, ints etc.
|
|
82
|
+
* Support for any type of object factories: function, coroutine, generator,
|
|
83
|
+
asynchronous generator.
|
|
84
|
+
* Automatic resource management via generator-based factories
|
|
85
|
+
(similar to pytest's fixtures)
|
|
86
|
+
* Multiple environment support: testing, development, production etc.
|
|
87
|
+
* Limiting created object's lifetime to user-defined scopes: global,
|
|
88
|
+
application, use-case etc.
|
|
89
|
+
* No singletons used, so there is no global state...
|
|
90
|
+
* ...but you still can create global injector on your own if you need it :-)
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
You can install PyDIO using one of following methods:
|
|
95
|
+
|
|
96
|
+
1) From PyPI (for stable releases):
|
|
97
|
+
|
|
98
|
+
```shell
|
|
99
|
+
$ pip install PyDIO
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2) From test PyPI (for stable and development releases):
|
|
103
|
+
|
|
104
|
+
```shell
|
|
105
|
+
$ pip install -i https://test.pypi.org/simple/ PyDIO
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3) Directly from source code repository (for all releases):
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
$ pip install git+https://gitlab.com/zef1r/PyDIO.git@[branch-or-tag]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
You have two options available:
|
|
117
|
+
|
|
118
|
+
1) Visit [PyDIO's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.
|
|
119
|
+
|
|
120
|
+
2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).
|
|
121
|
+
|
|
122
|
+
## Disclaimer
|
|
123
|
+
|
|
124
|
+
**PyDIO** is an independent open-source project in the Python ecosystem. It
|
|
125
|
+
is not affiliated with, sponsored by, or endorsed by any company, organization,
|
|
126
|
+
or product of the same or similar name. Any similarity in names is purely
|
|
127
|
+
coincidental and does not imply any association.
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
This project is released under the terms of the MIT license.
|
|
132
|
+
|
|
133
|
+
See [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.
|
|
134
|
+
|
|
135
|
+
## Author
|
|
136
|
+
|
|
137
|
+
Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
pydio-0.5.0.dist-info/METADATA,sha256=ZRS_h7BoM0xkgOEzpKUPUOqb2spXNzjVoFpquoAvDPA,4289
|
|
2
|
+
pydio-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
3
|
+
pydio-0.5.0.dist-info/licenses/LICENSE.txt,sha256=Oni1tShtKI76I7-EosLpYFvdIYKwCYUDxk657HdHgxk,1082
|
|
4
|
+
pydio-0.5.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|