PyDIO 0.5.0__tar.gz
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.
- pydio-0.5.0/.bumpify.toml +27 -0
- pydio-0.5.0/.circleci/config.yml +136 -0
- pydio-0.5.0/.gitignore +13 -0
- pydio-0.5.0/CHANGELOG.md +84 -0
- pydio-0.5.0/LICENSE.txt +19 -0
- pydio-0.5.0/PKG-INFO +137 -0
- pydio-0.5.0/README.md +118 -0
- pydio-0.5.0/docs/source/api/index.rst +20 -0
- pydio-0.5.0/docs/source/api/pydio/api.rst +5 -0
- pydio-0.5.0/docs/source/api/pydio/base.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/exc.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/injector.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/keys.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/provider.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/api.rst +5 -0
- pydio-0.5.0/docs/source/api/pydio/v1/async_backends/asyncio.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/async_backends.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/exc.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/helpers.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/injectors.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/interface.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1/providers.rst +4 -0
- pydio-0.5.0/docs/source/api/pydio/v1.rst +4 -0
- pydio-0.5.0/docs/source/changelog.rst +17 -0
- pydio-0.5.0/docs/source/conf.py +82 -0
- pydio-0.5.0/docs/source/index.rst +96 -0
- pydio-0.5.0/docs/source/installation.rst +28 -0
- pydio-0.5.0/docs/source/license.rst +16 -0
- pydio-0.5.0/docs/source/quickstart.rst +907 -0
- pydio-0.5.0/invoke.yml +3 -0
- pydio-0.5.0/pydio/__init__.py +13 -0
- pydio-0.5.0/pydio/_compat.py +13 -0
- pydio-0.5.0/pydio/_factories.py +129 -0
- pydio-0.5.0/pydio/_unbound_factories.py +77 -0
- pydio-0.5.0/pydio/api.py +30 -0
- pydio-0.5.0/pydio/base.py +208 -0
- pydio-0.5.0/pydio/exc.py +60 -0
- pydio-0.5.0/pydio/injector.py +228 -0
- pydio-0.5.0/pydio/keys.py +53 -0
- pydio-0.5.0/pydio/provider.py +148 -0
- pydio-0.5.0/pydio/v1/__init__.py +152 -0
- pydio-0.5.0/pydio/v1/_adapters.py +240 -0
- pydio-0.5.0/pydio/v1/_compat/__init__.py +14 -0
- pydio-0.5.0/pydio/v1/_compat/default.py +61 -0
- pydio-0.5.0/pydio/v1/_compat/py313.py +68 -0
- pydio-0.5.0/pydio/v1/_export_list.py +15 -0
- pydio-0.5.0/pydio/v1/_factories.py +146 -0
- pydio-0.5.0/pydio/v1/_utils.py +194 -0
- pydio-0.5.0/pydio/v1/api.py +20 -0
- pydio-0.5.0/pydio/v1/async_backends/__init__.py +13 -0
- pydio-0.5.0/pydio/v1/async_backends/asyncio.py +56 -0
- pydio-0.5.0/pydio/v1/exc.py +340 -0
- pydio-0.5.0/pydio/v1/helpers.py +290 -0
- pydio-0.5.0/pydio/v1/injectors.py +294 -0
- pydio-0.5.0/pydio/v1/interface.py +523 -0
- pydio-0.5.0/pydio/v1/providers.py +107 -0
- pydio-0.5.0/pyproject.toml +57 -0
- pydio-0.5.0/scripts/licenser/licenser.py +187 -0
- pydio-0.5.0/scripts/licenser/templates/license.txt +19 -0
- pydio-0.5.0/scripts/licenser/templates/preamble.py.txt +10 -0
- pydio-0.5.0/scripts/licenser/templates/preamble.rst.txt +11 -0
- pydio-0.5.0/scripts/tag.py +205 -0
- pydio-0.5.0/tasks.py +150 -0
- pydio-0.5.0/tests/__init__.py +10 -0
- pydio-0.5.0/tests/examples/__init__.py +10 -0
- pydio-0.5.0/tests/examples/test_database_session_management.py +146 -0
- pydio-0.5.0/tests/functional/__init__.py +10 -0
- pydio-0.5.0/tests/functional/conftest.py +20 -0
- pydio-0.5.0/tests/functional/test_async_generator_based_provider.py +126 -0
- pydio-0.5.0/tests/functional/test_basics.py +58 -0
- pydio-0.5.0/tests/functional/test_coroutine_based_provider.py +59 -0
- pydio-0.5.0/tests/functional/test_generator_based_provider.py +105 -0
- pydio-0.5.0/tests/functional/test_provider_grouping.py +40 -0
- pydio-0.5.0/tests/functional/test_provider_with_env.py +75 -0
- pydio-0.5.0/tests/functional/test_scoped_injector.py +155 -0
- pydio-0.5.0/tests/functional/test_using_multiple_threads.py +47 -0
- pydio-0.5.0/tests/functional/test_using_variant.py +48 -0
- pydio-0.5.0/tests/stubs.py +34 -0
- pydio-0.5.0/tests/unit/__init__.py +10 -0
- pydio-0.5.0/tests/unit/test_factories.py +137 -0
- pydio-0.5.0/tests/unit/test_injector.py +78 -0
- pydio-0.5.0/tests/unit/test_keys.py +25 -0
- pydio-0.5.0/tests/unit/test_provider.py +61 -0
- pydio-0.5.0/tests/v1/__init__.py +0 -0
- pydio-0.5.0/tests/v1/conftest.py +10 -0
- pydio-0.5.0/tests/v1/functional/__init__.py +0 -0
- pydio-0.5.0/tests/v1/functional/conftest.py +6 -0
- pydio-0.5.0/tests/v1/functional/test_async_dependency_resolving.py +68 -0
- pydio-0.5.0/tests/v1/functional/test_async_error_handling.py +133 -0
- pydio-0.5.0/tests/v1/functional/test_dependency_resolving.py +68 -0
- pydio-0.5.0/tests/v1/functional/test_error_handling.py +133 -0
- pydio-0.5.0/tests/v1/functional/test_multitask_safety.py +31 -0
- pydio-0.5.0/tests/v1/functional/test_multithread_safety.py +33 -0
- pydio-0.5.0/tests/v1/functional/test_using_annotated.py +47 -0
- pydio-0.5.0/tests/v1/functional/test_using_multiple_environments.py +68 -0
- pydio-0.5.0/tests/v1/functional/test_using_multiple_providers.py +76 -0
- pydio-0.5.0/tests/v1/functional/test_using_scopes.py +72 -0
- pydio-0.5.0/tests/v1/functional/types.py +13 -0
- pydio-0.5.0/tests/v1/unit/__init__.py +0 -0
- pydio-0.5.0/tests/v1/unit/async_backends/__init__.py +0 -0
- pydio-0.5.0/tests/v1/unit/async_backends/test_asyncio.py +77 -0
- pydio-0.5.0/tests/v1/unit/conftest.py +40 -0
- pydio-0.5.0/tests/v1/unit/stubs.py +53 -0
- pydio-0.5.0/tests/v1/unit/test_adapters.py +430 -0
- pydio-0.5.0/tests/v1/unit/test_exc.py +215 -0
- pydio-0.5.0/tests/v1/unit/test_export_list.py +46 -0
- pydio-0.5.0/tests/v1/unit/test_factories.py +218 -0
- pydio-0.5.0/tests/v1/unit/test_helpers.py +170 -0
- pydio-0.5.0/tests/v1/unit/test_injectors.py +629 -0
- pydio-0.5.0/tests/v1/unit/test_providers.py +159 -0
- pydio-0.5.0/uv.lock +1718 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[vcs]
|
|
2
|
+
type = "git"
|
|
3
|
+
|
|
4
|
+
[semver]
|
|
5
|
+
version = "0.0.1"
|
|
6
|
+
bump_commit_message_template = "bump: {prev_version_str} -> {version_str} [skip ci]"
|
|
7
|
+
version_tag_name_template = "v{version_str}"
|
|
8
|
+
|
|
9
|
+
[[semver.bump_rules]]
|
|
10
|
+
branch = "master"
|
|
11
|
+
when_breaking = "minor"
|
|
12
|
+
when_feat = "minor"
|
|
13
|
+
when_fix = "patch"
|
|
14
|
+
|
|
15
|
+
[[semver.version_files]]
|
|
16
|
+
path = "pyproject.toml"
|
|
17
|
+
prefix = "version"
|
|
18
|
+
encoding = "utf-8"
|
|
19
|
+
|
|
20
|
+
[[semver.version_files]]
|
|
21
|
+
path = "pydio/__init__.py"
|
|
22
|
+
prefix = "__version__"
|
|
23
|
+
encoding = "utf-8"
|
|
24
|
+
|
|
25
|
+
[[semver.changelog_files]]
|
|
26
|
+
path = "CHANGELOG.md"
|
|
27
|
+
encoding = "utf-8"
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
commands:
|
|
4
|
+
install-deps:
|
|
5
|
+
parameters:
|
|
6
|
+
ver_major:
|
|
7
|
+
type: integer
|
|
8
|
+
ver_minor:
|
|
9
|
+
type: integer
|
|
10
|
+
steps:
|
|
11
|
+
- restore_cache:
|
|
12
|
+
name: restore dependency cache
|
|
13
|
+
keys:
|
|
14
|
+
- py<<parameters.ver_major>><<parameters.ver_minor>>-{{ checksum "uv.lock" }}
|
|
15
|
+
- run: uv python pin <<parameters.ver_major>>.<<parameters.ver_minor>>
|
|
16
|
+
- run: uv sync
|
|
17
|
+
- save_cache:
|
|
18
|
+
name: save dependency cache
|
|
19
|
+
key: py<<parameters.ver_major>><<parameters.ver_minor>>-{{ checksum "uv.lock" }}
|
|
20
|
+
paths:
|
|
21
|
+
- .venv
|
|
22
|
+
configure-git:
|
|
23
|
+
steps:
|
|
24
|
+
- run: git config user.name "CircleCI"
|
|
25
|
+
- run: git config user.email "noreply@circleci.com"
|
|
26
|
+
push-to-git:
|
|
27
|
+
steps:
|
|
28
|
+
- run: git push --set-upstream origin $CIRCLE_BRANCH
|
|
29
|
+
- run: git push --tags
|
|
30
|
+
publish-coverage:
|
|
31
|
+
steps:
|
|
32
|
+
- run: uv run inv check-coverage -f0
|
|
33
|
+
- run: curl -Os https://uploader.codecov.io/latest/linux/codecov
|
|
34
|
+
- run: chmod +x codecov
|
|
35
|
+
- run: ./codecov
|
|
36
|
+
|
|
37
|
+
jobs:
|
|
38
|
+
test:
|
|
39
|
+
docker:
|
|
40
|
+
- image: cimg/python:<<parameters.ver_major>>.<<parameters.ver_minor>>
|
|
41
|
+
parameters:
|
|
42
|
+
ver_minor:
|
|
43
|
+
type: integer
|
|
44
|
+
ver_major:
|
|
45
|
+
type: integer
|
|
46
|
+
steps:
|
|
47
|
+
- checkout
|
|
48
|
+
- install-deps:
|
|
49
|
+
ver_major: <<parameters.ver_major>>
|
|
50
|
+
ver_minor: <<parameters.ver_minor>>
|
|
51
|
+
- run: uv run inv check
|
|
52
|
+
publish-coverage:
|
|
53
|
+
docker:
|
|
54
|
+
- image: cimg/python:3.9
|
|
55
|
+
steps:
|
|
56
|
+
- checkout
|
|
57
|
+
- configure-git
|
|
58
|
+
- install-deps:
|
|
59
|
+
ver_major: 3
|
|
60
|
+
ver_minor: 9
|
|
61
|
+
- publish-coverage
|
|
62
|
+
tag:
|
|
63
|
+
docker:
|
|
64
|
+
- image: cimg/python:3.9
|
|
65
|
+
steps:
|
|
66
|
+
- checkout
|
|
67
|
+
- configure-git
|
|
68
|
+
- install-deps:
|
|
69
|
+
ver_major: 3
|
|
70
|
+
ver_minor: 9
|
|
71
|
+
- run: uv tool install --python 3.9 bumpify
|
|
72
|
+
- run: bumpify --dry-run bump
|
|
73
|
+
- run: bumpify bump
|
|
74
|
+
- push-to-git
|
|
75
|
+
deploy:
|
|
76
|
+
docker:
|
|
77
|
+
- image: cimg/python:3.9
|
|
78
|
+
steps:
|
|
79
|
+
- checkout
|
|
80
|
+
- install-deps:
|
|
81
|
+
ver_major: 3
|
|
82
|
+
ver_minor: 9
|
|
83
|
+
- run: uv build
|
|
84
|
+
- run: uv publish --token $PYPI_TOKEN --dry-run
|
|
85
|
+
- run: uv publish --token $PYPI_TOKEN
|
|
86
|
+
|
|
87
|
+
workflows:
|
|
88
|
+
test:
|
|
89
|
+
jobs:
|
|
90
|
+
- test:
|
|
91
|
+
name: "test-py39"
|
|
92
|
+
ver_major: 3
|
|
93
|
+
ver_minor: 9
|
|
94
|
+
- test:
|
|
95
|
+
name: "test-py310"
|
|
96
|
+
ver_major: 3
|
|
97
|
+
ver_minor: 10
|
|
98
|
+
- test:
|
|
99
|
+
name: "test-py311"
|
|
100
|
+
ver_major: 3
|
|
101
|
+
ver_minor: 11
|
|
102
|
+
- test:
|
|
103
|
+
name: "test-py312"
|
|
104
|
+
ver_major: 3
|
|
105
|
+
ver_minor: 12
|
|
106
|
+
- test:
|
|
107
|
+
name: "test-py313"
|
|
108
|
+
ver_major: 3
|
|
109
|
+
ver_minor: 13
|
|
110
|
+
- test:
|
|
111
|
+
name: "test-py314"
|
|
112
|
+
ver_major: 3
|
|
113
|
+
ver_minor: 14
|
|
114
|
+
- publish-coverage:
|
|
115
|
+
filters:
|
|
116
|
+
branches:
|
|
117
|
+
only: master
|
|
118
|
+
- tag:
|
|
119
|
+
requires:
|
|
120
|
+
- test-py39
|
|
121
|
+
- test-py310
|
|
122
|
+
- test-py311
|
|
123
|
+
- test-py312
|
|
124
|
+
- test-py313
|
|
125
|
+
- test-py314
|
|
126
|
+
filters:
|
|
127
|
+
branches:
|
|
128
|
+
only: master
|
|
129
|
+
tags:
|
|
130
|
+
ignore: /.*/
|
|
131
|
+
- deploy:
|
|
132
|
+
filters:
|
|
133
|
+
branches:
|
|
134
|
+
ignore: /.*/
|
|
135
|
+
tags:
|
|
136
|
+
only: /^v.*$/
|
pydio-0.5.0/.gitignore
ADDED
pydio-0.5.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
## 0.5.0 (2026-10-20)
|
|
2
|
+
|
|
3
|
+
### Fix
|
|
4
|
+
|
|
5
|
+
- when `OutOfScopeError` is raised from a child provider, collect it and raise summarized error
|
|
6
|
+
- make tests pass on Python 3.13
|
|
7
|
+
- fix package publishing
|
|
8
|
+
- add CI skipping postfix to bump commits
|
|
9
|
+
- detach closed scoped injector from its parent
|
|
10
|
+
- use `bumpify` but as a separately installed tool
|
|
11
|
+
- migrate `pyproject.toml` to PEP-621
|
|
12
|
+
|
|
13
|
+
### Feat
|
|
14
|
+
|
|
15
|
+
- add support for Python 3.12 and 3.13
|
|
16
|
+
- add a new v1 `provides` decorator
|
|
17
|
+
- create a v1 `Injector` implementation with tests
|
|
18
|
+
- add v1 `AsyncInjector` implementation with tests
|
|
19
|
+
- add async recursive lock implementation for a default asyncio backend
|
|
20
|
+
- add `inject_annotated` and `async_inject_annotated` helpers
|
|
21
|
+
- normalize exception handling
|
|
22
|
+
- add support for Python 3.14
|
|
23
|
+
|
|
24
|
+
## 0.4.1 (2023-05-12)
|
|
25
|
+
|
|
26
|
+
### Fix
|
|
27
|
+
|
|
28
|
+
- properly close injector when exception thrown in teardown phase
|
|
29
|
+
|
|
30
|
+
## 0.4.0 (2023-05-06)
|
|
31
|
+
|
|
32
|
+
### Fix
|
|
33
|
+
|
|
34
|
+
- resolve issue #7
|
|
35
|
+
|
|
36
|
+
### Feat
|
|
37
|
+
|
|
38
|
+
- extend API of IFactory.close for the purpose of solving issue #7
|
|
39
|
+
- add support for Python 3.11
|
|
40
|
+
|
|
41
|
+
## 0.3.3 (2022-11-05)
|
|
42
|
+
|
|
43
|
+
### Fix
|
|
44
|
+
|
|
45
|
+
- deploy task no longer requires test jobs
|
|
46
|
+
|
|
47
|
+
## 0.3.2 (2022-11-05)
|
|
48
|
+
|
|
49
|
+
### Fix
|
|
50
|
+
|
|
51
|
+
- fix config.yml so that the job is triggered once tag is pushed
|
|
52
|
+
|
|
53
|
+
## 0.3.1 (2022-11-05)
|
|
54
|
+
|
|
55
|
+
### Fix
|
|
56
|
+
|
|
57
|
+
- make Changelog chapter in Sphinx documentation work again
|
|
58
|
+
|
|
59
|
+
## 0.3.0 (2022-11-05)
|
|
60
|
+
|
|
61
|
+
### Feat
|
|
62
|
+
|
|
63
|
+
- remove compatibility layer for no longer supported Python 3.6
|
|
64
|
+
|
|
65
|
+
## 0.2.1 (2022-11-05)
|
|
66
|
+
|
|
67
|
+
### Fix
|
|
68
|
+
|
|
69
|
+
- fix various CI issues (#6)
|
|
70
|
+
|
|
71
|
+
## 0.2.0 (2022-10-30)
|
|
72
|
+
|
|
73
|
+
## 0.1.0 (2021-02-15)
|
|
74
|
+
|
|
75
|
+
## 0.1.0 (2021-02-10)
|
|
76
|
+
|
|
77
|
+
## 0.1.0 (2021-02-04)
|
|
78
|
+
|
|
79
|
+
## 0.1.0 (2021-02-04)
|
|
80
|
+
|
|
81
|
+
## 0.1.0 (2021-02-04)
|
|
82
|
+
|
|
83
|
+
Initial release.
|
|
84
|
+
|
pydio-0.5.0/LICENSE.txt
ADDED
|
@@ -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.
|
pydio-0.5.0/PKG-INFO
ADDED
|
@@ -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>
|
pydio-0.5.0/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://codecov.io/gh/mwiatrzyk/pydio)
|
|
6
|
+
|
|
7
|
+
# PyDIO
|
|
8
|
+
|
|
9
|
+
Lightweight and functional dependency injection library for Python.
|
|
10
|
+
|
|
11
|
+
## Name
|
|
12
|
+
|
|
13
|
+
**PyDIO** (stylized as *PyDIO*, installable as `pydio`, pronounced
|
|
14
|
+
*"pie-dee-o"*) stands for **Python dependency injection library**.
|
|
15
|
+
|
|
16
|
+
## About
|
|
17
|
+
|
|
18
|
+
PyDIO aims to be simple, yet still powerful, allowing you to feed dependencies
|
|
19
|
+
inside your application in a flexible way. PyDIO design is based on simple
|
|
20
|
+
assumption that dependency injection can be achieved using a straightforward
|
|
21
|
+
**key-to-function** mapping, where **key** specifies **type of object** you
|
|
22
|
+
want to inject and **function** is a **factory** function that creates
|
|
23
|
+
**instances** of that type.
|
|
24
|
+
|
|
25
|
+
In PyDIO, this is implemented using **providers** and **injectors**. You use
|
|
26
|
+
providers to configure your **key-to-function** mapping, and then you use
|
|
27
|
+
injectors to perform a **lookup** of a specific key and creation of the final
|
|
28
|
+
object.
|
|
29
|
+
|
|
30
|
+
Here's a simple example:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import abc
|
|
34
|
+
|
|
35
|
+
from pydio.api import Provider, Injector
|
|
36
|
+
|
|
37
|
+
provider = Provider()
|
|
38
|
+
|
|
39
|
+
@provider.provides('greet')
|
|
40
|
+
def make_greet():
|
|
41
|
+
return 'Hello, world!'
|
|
42
|
+
|
|
43
|
+
def main():
|
|
44
|
+
injector = Injector(provider)
|
|
45
|
+
greet_message = injector.inject('greet')
|
|
46
|
+
print(greet_message)
|
|
47
|
+
|
|
48
|
+
if __name__ == '__main__':
|
|
49
|
+
main()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Now you can save the snippet from above as ``example.py`` file and execute
|
|
53
|
+
to see the output:
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
$ python example.py
|
|
57
|
+
Hello, world!
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Key features
|
|
61
|
+
|
|
62
|
+
* Support for any hashable keys: class objects, strings, ints etc.
|
|
63
|
+
* Support for any type of object factories: function, coroutine, generator,
|
|
64
|
+
asynchronous generator.
|
|
65
|
+
* Automatic resource management via generator-based factories
|
|
66
|
+
(similar to pytest's fixtures)
|
|
67
|
+
* Multiple environment support: testing, development, production etc.
|
|
68
|
+
* Limiting created object's lifetime to user-defined scopes: global,
|
|
69
|
+
application, use-case etc.
|
|
70
|
+
* No singletons used, so there is no global state...
|
|
71
|
+
* ...but you still can create global injector on your own if you need it :-)
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
You can install PyDIO using one of following methods:
|
|
76
|
+
|
|
77
|
+
1) From PyPI (for stable releases):
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
$ pip install PyDIO
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2) From test PyPI (for stable and development releases):
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
$ pip install -i https://test.pypi.org/simple/ PyDIO
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3) Directly from source code repository (for all releases):
|
|
90
|
+
|
|
91
|
+
```shell
|
|
92
|
+
$ pip install git+https://gitlab.com/zef1r/PyDIO.git@[branch-or-tag]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
You have two options available:
|
|
98
|
+
|
|
99
|
+
1) Visit [PyDIO's ReadTheDocs](https://pydio.readthedocs.io/en/latest/) site.
|
|
100
|
+
|
|
101
|
+
2) Take a tour around [functional tests](https://github.com/mwiatrzyk/pydio/tree/master/tests/functional).
|
|
102
|
+
|
|
103
|
+
## Disclaimer
|
|
104
|
+
|
|
105
|
+
**PyDIO** is an independent open-source project in the Python ecosystem. It
|
|
106
|
+
is not affiliated with, sponsored by, or endorsed by any company, organization,
|
|
107
|
+
or product of the same or similar name. Any similarity in names is purely
|
|
108
|
+
coincidental and does not imply any association.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
This project is released under the terms of the MIT license.
|
|
113
|
+
|
|
114
|
+
See [LICENSE.txt](https://github.com/mwiatrzyk/pydio/blob/master/LICENSE.txt) for more details.
|
|
115
|
+
|
|
116
|
+
## Author
|
|
117
|
+
|
|
118
|
+
Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
.. toctree::
|
|
4
|
+
:maxdepth: 1
|
|
5
|
+
|
|
6
|
+
pydio/api
|
|
7
|
+
pydio/base
|
|
8
|
+
pydio/exc
|
|
9
|
+
pydio/injector
|
|
10
|
+
pydio/keys
|
|
11
|
+
pydio/provider
|
|
12
|
+
pydio/v1
|
|
13
|
+
pydio/v1/api
|
|
14
|
+
pydio/v1/async_backends
|
|
15
|
+
pydio/v1/async_backends/asyncio
|
|
16
|
+
pydio/v1/exc
|
|
17
|
+
pydio/v1/helpers
|
|
18
|
+
pydio/v1/injectors
|
|
19
|
+
pydio/v1/interface
|
|
20
|
+
pydio/v1/providers
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.. ----------------------------------------------------------------------------
|
|
2
|
+
.. docs/source/changelog.rst
|
|
3
|
+
..
|
|
4
|
+
.. Copyright (C) 2021 - 2025 Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>
|
|
5
|
+
..
|
|
6
|
+
.. This file is part of PyDio library documentation
|
|
7
|
+
.. and is released under the terms of the MIT license:
|
|
8
|
+
.. http://opensource.org/licenses/mit-license.php.
|
|
9
|
+
..
|
|
10
|
+
.. See LICENSE.txt for details.
|
|
11
|
+
.. ----------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
Changelog
|
|
14
|
+
=========
|
|
15
|
+
|
|
16
|
+
.. include:: ../../CHANGELOG.md
|
|
17
|
+
:parser: myst_parser.sphinx_
|