poetry-plugin-dotenv 2.2.3__tar.gz → 2.3.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.
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/PKG-INFO +17 -17
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/README.md +15 -15
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/pyproject.toml +13 -14
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/__init__.py +1 -1
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/config.py +26 -23
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/core.py +16 -31
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/parsers.py +33 -40
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/variables.py +8 -9
- poetry_plugin_dotenv-2.3.0/src/poetry_plugin_dotenv/exceptions.py +11 -0
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/logger.py +18 -14
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/plugin.py +23 -22
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/LICENSE +0 -0
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/__init__.py +0 -0
- {poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: poetry-plugin-dotenv
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run.
|
|
5
5
|
Home-page: https://github.com/pivoshenko/poetry-plugin-dotenv
|
|
6
6
|
License: MIT
|
|
@@ -28,7 +28,7 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
28
28
|
Classifier: Topic :: Software Development
|
|
29
29
|
Classifier: Topic :: Software Development :: Libraries
|
|
30
30
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
31
|
-
Requires-Dist: poetry (>=1.
|
|
31
|
+
Requires-Dist: poetry (>=1.8.3)
|
|
32
32
|
Project-URL: Documentation, https://github.com/pivoshenko/poetry-plugin-dotenv
|
|
33
33
|
Project-URL: Issues, https://github.com/pivoshenko/poetry-plugin-dotenv/issues
|
|
34
34
|
Project-URL: Repository, https://github.com/pivoshenko/poetry-plugin-dotenv
|
|
@@ -44,28 +44,28 @@ Description-Content-Type: text/markdown
|
|
|
44
44
|
|
|
45
45
|
<p align="center">
|
|
46
46
|
<a href="https://opensource.org/licenses/MIT">
|
|
47
|
-
<img alt="
|
|
47
|
+
<img alt="License" src="https://img.shields.io/pypi/l/poetry-plugin-dotenv?style=flat-square&logo=opensourceinitiative&logoColor=white&color=0A6847&label=License">
|
|
48
48
|
</a>
|
|
49
49
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
50
|
-
<img alt="
|
|
50
|
+
<img alt="Python" src="https://img.shields.io/pypi/pyversions/poetry-plugin-dotenv?style=flat-square&logo=python&logoColor=white&color=4856CD&label=Python">
|
|
51
51
|
</a>
|
|
52
52
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
53
|
-
<img alt="
|
|
53
|
+
<img alt="PyPI" src="https://img.shields.io/pypi/v/poetry-plugin-dotenv?style=flat-square&logo=pypi&logoColor=white&color=4856CD&label=PyPI">
|
|
54
54
|
</a>
|
|
55
55
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/releases">
|
|
56
|
-
<img alt="
|
|
56
|
+
<img alt="Release" src="https://img.shields.io/github/v/release/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=github&logoColor=white&color=4856CD&label=Release">
|
|
57
57
|
</a>
|
|
58
58
|
</p>
|
|
59
59
|
|
|
60
60
|
<p align="center">
|
|
61
61
|
<a href="https://github.com/semantic-release/semantic-release">
|
|
62
|
-
<img alt="
|
|
62
|
+
<img alt="Semantic_Release" src="https://img.shields.io/badge/Semantic_Release-angular-e10079?style=flat-square&logo=semanticrelease&logoColor=white&color=D83A56">
|
|
63
63
|
</a>
|
|
64
64
|
<a href="https://github.com/PyCQA/isort">
|
|
65
|
-
<img alt="
|
|
65
|
+
<img alt="Imports" src="https://img.shields.io/badge/Imports-isort-black.svg?style=flat-square&logo=improvmx&logoColor=white&color=637A9F&">
|
|
66
66
|
</a>
|
|
67
67
|
<a href="https://beta.ruff.rs/docs/">
|
|
68
|
-
<img alt="
|
|
68
|
+
<img alt="Ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json&style=flat-square&logoColor=white&color=637A9F">
|
|
69
69
|
</a>
|
|
70
70
|
<a href="https://mypy.readthedocs.io/en/stable/index.html">
|
|
71
71
|
<img alt="mypy" src="https://img.shields.io/badge/mypy-checked-success.svg?style=flat-square&logo=pypy&logoColor=white&color=0A6847">
|
|
@@ -74,34 +74,34 @@ Description-Content-Type: text/markdown
|
|
|
74
74
|
|
|
75
75
|
<p align="center">
|
|
76
76
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/tests.yaml">
|
|
77
|
-
<img alt="
|
|
77
|
+
<img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/tests.yaml?label=Tests&style=flat-square&logo=pytest&logoColor=white&color=0A6847">
|
|
78
78
|
</a>
|
|
79
79
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/linters.yaml">
|
|
80
|
-
<img alt="
|
|
80
|
+
<img alt="Linters" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/linters.yaml?label=Linters&style=flat-square&logo=lintcode&logoColor=white&color=0A6847">
|
|
81
81
|
</a>
|
|
82
82
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/release.yaml">
|
|
83
|
-
<img alt="
|
|
83
|
+
<img alt="Release" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/release.yaml?label=Release&style=flat-square&logo=pypi&logoColor=white&color=0A6847">
|
|
84
84
|
</a>
|
|
85
85
|
<a href="https://codecov.io/gh/pivoshenko/poetry-plugin-dotenv" >
|
|
86
|
-
<img alt="
|
|
86
|
+
<img alt="Codecov" src="https://img.shields.io/codecov/c/gh/pivoshenko/poetry-plugin-dotenv?token=cqRQxVnDR6&style=flat-square&logo=codecov&logoColor=white&color=0A6847&label=Coverage"/>
|
|
87
87
|
</a>
|
|
88
88
|
</p>
|
|
89
89
|
|
|
90
90
|
<p align="center">
|
|
91
91
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
92
|
-
<img alt="
|
|
92
|
+
<img alt="Downloads" src="https://img.shields.io/pypi/dm/poetry-plugin-dotenv?style=flat-square&logo=pythonanywhere&logoColor=white&color=4856CD&label=Downloads">
|
|
93
93
|
</a>
|
|
94
94
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/">
|
|
95
|
-
<img alt="
|
|
95
|
+
<img alt="Stars" src="https://img.shields.io/github/stars/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=apachespark&logoColor=white&color=4856CD&label=Stars">
|
|
96
96
|
</a>
|
|
97
97
|
</p>
|
|
98
98
|
|
|
99
99
|
<p align="center">
|
|
100
100
|
<a href="https://stand-with-ukraine.pp.ua/">
|
|
101
|
-
<img alt="
|
|
101
|
+
<img alt="StandWithUkraine" src="https://img.shields.io/badge/Support-Ukraine-FFC93C?style=flat-square&labelColor=07689F">
|
|
102
102
|
</a>
|
|
103
103
|
<a href="https://stand-with-ukraine.pp.ua">
|
|
104
|
-
<img alt="
|
|
104
|
+
<img alt="StandWithUkraine" src="https://img.shields.io/badge/Made_in-Ukraine-FFC93C.svg?style=flat-square&labelColor=07689F">
|
|
105
105
|
</a>
|
|
106
106
|
</p>
|
|
107
107
|
|
|
@@ -6,28 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://opensource.org/licenses/MIT">
|
|
9
|
-
<img alt="
|
|
9
|
+
<img alt="License" src="https://img.shields.io/pypi/l/poetry-plugin-dotenv?style=flat-square&logo=opensourceinitiative&logoColor=white&color=0A6847&label=License">
|
|
10
10
|
</a>
|
|
11
11
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
12
|
-
<img alt="
|
|
12
|
+
<img alt="Python" src="https://img.shields.io/pypi/pyversions/poetry-plugin-dotenv?style=flat-square&logo=python&logoColor=white&color=4856CD&label=Python">
|
|
13
13
|
</a>
|
|
14
14
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
15
|
-
<img alt="
|
|
15
|
+
<img alt="PyPI" src="https://img.shields.io/pypi/v/poetry-plugin-dotenv?style=flat-square&logo=pypi&logoColor=white&color=4856CD&label=PyPI">
|
|
16
16
|
</a>
|
|
17
17
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/releases">
|
|
18
|
-
<img alt="
|
|
18
|
+
<img alt="Release" src="https://img.shields.io/github/v/release/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=github&logoColor=white&color=4856CD&label=Release">
|
|
19
19
|
</a>
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
22
|
<p align="center">
|
|
23
23
|
<a href="https://github.com/semantic-release/semantic-release">
|
|
24
|
-
<img alt="
|
|
24
|
+
<img alt="Semantic_Release" src="https://img.shields.io/badge/Semantic_Release-angular-e10079?style=flat-square&logo=semanticrelease&logoColor=white&color=D83A56">
|
|
25
25
|
</a>
|
|
26
26
|
<a href="https://github.com/PyCQA/isort">
|
|
27
|
-
<img alt="
|
|
27
|
+
<img alt="Imports" src="https://img.shields.io/badge/Imports-isort-black.svg?style=flat-square&logo=improvmx&logoColor=white&color=637A9F&">
|
|
28
28
|
</a>
|
|
29
29
|
<a href="https://beta.ruff.rs/docs/">
|
|
30
|
-
<img alt="
|
|
30
|
+
<img alt="Ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json&style=flat-square&logoColor=white&color=637A9F">
|
|
31
31
|
</a>
|
|
32
32
|
<a href="https://mypy.readthedocs.io/en/stable/index.html">
|
|
33
33
|
<img alt="mypy" src="https://img.shields.io/badge/mypy-checked-success.svg?style=flat-square&logo=pypy&logoColor=white&color=0A6847">
|
|
@@ -36,34 +36,34 @@
|
|
|
36
36
|
|
|
37
37
|
<p align="center">
|
|
38
38
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/tests.yaml">
|
|
39
|
-
<img alt="
|
|
39
|
+
<img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/tests.yaml?label=Tests&style=flat-square&logo=pytest&logoColor=white&color=0A6847">
|
|
40
40
|
</a>
|
|
41
41
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/linters.yaml">
|
|
42
|
-
<img alt="
|
|
42
|
+
<img alt="Linters" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/linters.yaml?label=Linters&style=flat-square&logo=lintcode&logoColor=white&color=0A6847">
|
|
43
43
|
</a>
|
|
44
44
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/actions/workflows/release.yaml">
|
|
45
|
-
<img alt="
|
|
45
|
+
<img alt="Release" src="https://img.shields.io/github/actions/workflow/status/pivoshenko/poetry-plugin-dotenv/release.yaml?label=Release&style=flat-square&logo=pypi&logoColor=white&color=0A6847">
|
|
46
46
|
</a>
|
|
47
47
|
<a href="https://codecov.io/gh/pivoshenko/poetry-plugin-dotenv" >
|
|
48
|
-
<img alt="
|
|
48
|
+
<img alt="Codecov" src="https://img.shields.io/codecov/c/gh/pivoshenko/poetry-plugin-dotenv?token=cqRQxVnDR6&style=flat-square&logo=codecov&logoColor=white&color=0A6847&label=Coverage"/>
|
|
49
49
|
</a>
|
|
50
50
|
</p>
|
|
51
51
|
|
|
52
52
|
<p align="center">
|
|
53
53
|
<a href="https://pypi.org/project/poetry-plugin-dotenv">
|
|
54
|
-
<img alt="
|
|
54
|
+
<img alt="Downloads" src="https://img.shields.io/pypi/dm/poetry-plugin-dotenv?style=flat-square&logo=pythonanywhere&logoColor=white&color=4856CD&label=Downloads">
|
|
55
55
|
</a>
|
|
56
56
|
<a href="https://github.com/pivoshenko/poetry-plugin-dotenv/">
|
|
57
|
-
<img alt="
|
|
57
|
+
<img alt="Stars" src="https://img.shields.io/github/stars/pivoshenko/poetry-plugin-dotenv?style=flat-square&logo=apachespark&logoColor=white&color=4856CD&label=Stars">
|
|
58
58
|
</a>
|
|
59
59
|
</p>
|
|
60
60
|
|
|
61
61
|
<p align="center">
|
|
62
62
|
<a href="https://stand-with-ukraine.pp.ua/">
|
|
63
|
-
<img alt="
|
|
63
|
+
<img alt="StandWithUkraine" src="https://img.shields.io/badge/Support-Ukraine-FFC93C?style=flat-square&labelColor=07689F">
|
|
64
64
|
</a>
|
|
65
65
|
<a href="https://stand-with-ukraine.pp.ua">
|
|
66
|
-
<img alt="
|
|
66
|
+
<img alt="StandWithUkraine" src="https://img.shields.io/badge/Made_in-Ukraine-FFC93C.svg?style=flat-square&labelColor=07689F">
|
|
67
67
|
</a>
|
|
68
68
|
</p>
|
|
69
69
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "poetry-plugin-dotenv"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run."
|
|
5
5
|
license = "MIT"
|
|
6
6
|
authors = ["Volodymyr Pivoshenko <volodymyr.pivoshenko@gmail.com>"]
|
|
@@ -54,29 +54,29 @@ packages = [{ include = "poetry_plugin_dotenv", from = "src" }]
|
|
|
54
54
|
|
|
55
55
|
[tool.poetry.dependencies]
|
|
56
56
|
python = ">=3.8.1,<4.0"
|
|
57
|
-
poetry = ">=1.
|
|
57
|
+
poetry = ">=1.8.3"
|
|
58
58
|
|
|
59
59
|
[tool.poetry.group.dev.dependencies]
|
|
60
60
|
pre-commit = ">=3.5.0"
|
|
61
|
-
poethepoet = ">=0.
|
|
61
|
+
poethepoet = ">=0.28.0"
|
|
62
62
|
ipdb = ">=0.13.13"
|
|
63
63
|
ipython = "8.12.3"
|
|
64
64
|
|
|
65
65
|
[tool.poetry.group.formatters.dependencies]
|
|
66
66
|
isort = ">=5.13.2"
|
|
67
|
-
ruff = ">=0.
|
|
67
|
+
ruff = ">=0.6.3"
|
|
68
68
|
pyupgrade = ">=3.16.0"
|
|
69
69
|
|
|
70
70
|
[tool.poetry.group.linters.dependencies]
|
|
71
|
-
mypy = ">=1.
|
|
72
|
-
ruff = ">=0.
|
|
73
|
-
deptry = ">=0.
|
|
71
|
+
mypy = ">=1.11.2"
|
|
72
|
+
ruff = ">=0.6.3"
|
|
73
|
+
deptry = ">=0.20.0"
|
|
74
74
|
codespell = ">=2.3.0"
|
|
75
|
-
commitizen = ">=3.
|
|
75
|
+
commitizen = ">=3.29.0"
|
|
76
76
|
|
|
77
77
|
[tool.poetry.group.lsp.dependencies]
|
|
78
|
-
python-lsp-server = { extras = ["all"], version = ">=1.
|
|
79
|
-
ruff-lsp = ">=0.0.
|
|
78
|
+
python-lsp-server = { extras = ["all"], version = ">=1.12.0" }
|
|
79
|
+
ruff-lsp = ">=0.0.55"
|
|
80
80
|
pylsp-mypy = ">=0.6.8"
|
|
81
81
|
pylsp-rope = ">=0.1.16"
|
|
82
82
|
python-lsp-isort = ">=0.1"
|
|
@@ -86,17 +86,17 @@ python-lsp-isort = ">=0.1"
|
|
|
86
86
|
# https://github.com/pytest-dev/pytest/issues/11890
|
|
87
87
|
# https://github.com/TvoroG/pytest-lazy-fixture/issues/65
|
|
88
88
|
pytest = "7.4.4"
|
|
89
|
-
xdoctest = ">=1.
|
|
89
|
+
xdoctest = ">=1.2.0"
|
|
90
90
|
pytest-lazy-fixture = ">=0.6.3"
|
|
91
91
|
pytest-codeblocks = ">=0.17.0"
|
|
92
92
|
pytest-mock = ">=3.14.0"
|
|
93
93
|
pytest-cov = ">=5.0.0"
|
|
94
94
|
pytest-sugar = ">=1.0.0"
|
|
95
|
-
coverage = { version = ">=7.
|
|
95
|
+
coverage = { version = ">=7.6.1", extras = ["toml"] }
|
|
96
96
|
sh = ">=2.0.7"
|
|
97
97
|
|
|
98
98
|
[tool.poetry.group.ci.dependencies]
|
|
99
|
-
python-semantic-release = ">=9.8.
|
|
99
|
+
python-semantic-release = ">=9.8.7"
|
|
100
100
|
|
|
101
101
|
[tool.poetry.plugins."poetry.application.plugin"]
|
|
102
102
|
poetry-plugin-dotenv = "poetry_plugin_dotenv.plugin:DotenvPlugin"
|
|
@@ -215,7 +215,6 @@ sequence = [
|
|
|
215
215
|
{ shell = "cz check --rev-range .", help = "Run commits linter" }
|
|
216
216
|
]
|
|
217
217
|
|
|
218
|
-
|
|
219
218
|
[build-system]
|
|
220
219
|
requires = ["poetry-core>=1.0.0"]
|
|
221
220
|
build-backend = "poetry.core.masonry.api"
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/__init__.py
RENAMED
|
@@ -7,7 +7,7 @@ __title__ = "poetry-plugin-dotenv"
|
|
|
7
7
|
__summary__ = "poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run."
|
|
8
8
|
__uri__ = "https://github.com/pivoshenko/poetry-plugin-dotenv"
|
|
9
9
|
|
|
10
|
-
__version__ = "2.
|
|
10
|
+
__version__ = "2.3.0"
|
|
11
11
|
|
|
12
12
|
__author__ = "Volodymyr Pivoshenko"
|
|
13
13
|
__email__ = "volodymyr.pivoshenko@gmail.com"
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/config.py
RENAMED
|
@@ -42,7 +42,9 @@ class Config(_Config):
|
|
|
42
42
|
"""Configuration loader."""
|
|
43
43
|
|
|
44
44
|
def __init__(self, working_dir: str) -> None:
|
|
45
|
-
"""Initialize."""
|
|
45
|
+
"""Initialize and load configuration from sources."""
|
|
46
|
+
|
|
47
|
+
super().__init__()
|
|
46
48
|
|
|
47
49
|
source_config = {}
|
|
48
50
|
for config_source, section in CONFIG_SOURCES.items():
|
|
@@ -57,51 +59,52 @@ class Config(_Config):
|
|
|
57
59
|
|
|
58
60
|
source_config.update(config)
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
self._apply_source_config(source_config)
|
|
63
|
+
|
|
64
|
+
def _apply_source_config(self, source_config: dict[str, str | bool | None]) -> None:
|
|
65
|
+
"""Apply source configuration to the instance."""
|
|
66
|
+
|
|
67
|
+
for attribute, default_value in self.__dataclass_fields__.items():
|
|
68
|
+
source_value = source_config.get(attribute)
|
|
63
69
|
|
|
64
|
-
# fmt: off
|
|
65
70
|
if (
|
|
66
|
-
isinstance(
|
|
67
|
-
and
|
|
68
|
-
and
|
|
71
|
+
isinstance(default_value.type, bool)
|
|
72
|
+
and source_value
|
|
73
|
+
and not isinstance(source_value, bool)
|
|
69
74
|
):
|
|
70
|
-
|
|
71
|
-
# fmt: on
|
|
75
|
+
source_value = _as_bool(source_value)
|
|
72
76
|
|
|
73
|
-
if
|
|
74
|
-
self
|
|
77
|
+
if source_value is not None:
|
|
78
|
+
setattr(self, attribute, source_value)
|
|
75
79
|
|
|
76
80
|
|
|
77
81
|
def _load_config_from_toml(filepath: str, section: str) -> dict[str, str | bool | None]:
|
|
78
82
|
"""Load configuration from the TOML file."""
|
|
79
83
|
|
|
80
|
-
if os.path.exists(filepath):
|
|
81
|
-
|
|
82
|
-
toml = tomlkit.load(toml_file)
|
|
84
|
+
if not os.path.exists(filepath):
|
|
85
|
+
return {}
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
config = config.get(key, {})
|
|
87
|
+
with open(filepath, "rb") as toml_file:
|
|
88
|
+
config = tomlkit.load(toml_file)
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
for key in section.split("."):
|
|
91
|
+
config = config.get(key, {})
|
|
89
92
|
|
|
90
|
-
return
|
|
93
|
+
return config if isinstance(config, dict) else {}
|
|
91
94
|
|
|
92
95
|
|
|
93
96
|
def _load_config_from_os(section: str) -> dict[str, str | bool | None]:
|
|
94
97
|
"""Load configuration from the OS environment variables."""
|
|
95
98
|
|
|
96
99
|
return {
|
|
97
|
-
key
|
|
100
|
+
key[len(section) :].lower(): value
|
|
98
101
|
for key, value in os.environ.items()
|
|
99
102
|
if key.startswith(section)
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
|
|
103
106
|
def _as_bool(value: str) -> bool:
|
|
104
|
-
"""
|
|
107
|
+
"""Convert a string value to a Boolean equivalent.
|
|
105
108
|
|
|
106
109
|
Heavily inspired from ``distutils strtobool``.
|
|
107
110
|
"""
|
|
@@ -110,5 +113,5 @@ def _as_bool(value: str) -> bool:
|
|
|
110
113
|
return _STR_BOOLEAN_MAPPING[value.lower()]
|
|
111
114
|
|
|
112
115
|
except KeyError:
|
|
113
|
-
msg = f"Invalid truth value {value}"
|
|
116
|
+
msg = f"Invalid truth value '{value}'"
|
|
114
117
|
raise ValueError(msg) from None
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/core.py
RENAMED
|
@@ -33,13 +33,11 @@ class DotEnv:
|
|
|
33
33
|
) -> None:
|
|
34
34
|
"""Initialize."""
|
|
35
35
|
|
|
36
|
+
self.filepath = filepath
|
|
36
37
|
self.stream = stream
|
|
37
38
|
self.override = override
|
|
38
|
-
self.filepath = filepath
|
|
39
39
|
self.interpolate = interpolate
|
|
40
|
-
|
|
41
40
|
self.encoding = "utf-8"
|
|
42
|
-
|
|
43
41
|
self._dict: OrderedDict[str, str] | None = None
|
|
44
42
|
|
|
45
43
|
def dict(self) -> OrderedDict[str, str]:
|
|
@@ -131,38 +129,30 @@ def resolve(
|
|
|
131
129
|
def walk_to_root(path: str) -> Iterator[str]:
|
|
132
130
|
"""Yield directories starting from the given directory up to the root."""
|
|
133
131
|
|
|
134
|
-
if not os.path.exists(path):
|
|
132
|
+
if not os.path.exists(path):
|
|
135
133
|
msg = "Starting path not found."
|
|
136
134
|
raise OSError(msg)
|
|
137
135
|
|
|
138
|
-
if os.path.isfile(path)
|
|
139
|
-
path = os.path.dirname(path) # pragma: nocover
|
|
140
|
-
|
|
141
|
-
last_dir = None
|
|
142
|
-
current_dir = os.path.abspath(path)
|
|
136
|
+
current_dir = os.path.abspath(os.path.dirname(path) if os.path.isfile(path) else path)
|
|
143
137
|
|
|
144
|
-
while
|
|
138
|
+
while True:
|
|
145
139
|
yield current_dir
|
|
146
|
-
parent_dir = os.path.abspath(os.path.join(current_dir, os.
|
|
147
|
-
last_dir, current_dir = current_dir, parent_dir
|
|
148
|
-
|
|
140
|
+
parent_dir = os.path.abspath(os.path.join(current_dir, os.pardir))
|
|
149
141
|
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
if current_dir == parent_dir:
|
|
143
|
+
break
|
|
152
144
|
|
|
153
|
-
|
|
154
|
-
path = os.getcwd()
|
|
145
|
+
current_dir = parent_dir
|
|
155
146
|
|
|
156
|
-
else: # pragma: no cover
|
|
157
|
-
frame = sys._getframe() # noqa: SLF001
|
|
158
|
-
current_file = __file__
|
|
159
147
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
frame = frame.f_back
|
|
148
|
+
def find(filename: str = ".env", *, usecwd: bool = False) -> str:
|
|
149
|
+
"""Search in increasingly higher folders for the given file."""
|
|
163
150
|
|
|
164
|
-
|
|
165
|
-
|
|
151
|
+
path = (
|
|
152
|
+
os.getcwd()
|
|
153
|
+
if usecwd or getattr(sys, "frozen", False)
|
|
154
|
+
else os.path.dirname(os.path.abspath(sys._getframe(1).f_code.co_filename)) # noqa: SLF001
|
|
155
|
+
)
|
|
166
156
|
|
|
167
157
|
for dirname in walk_to_root(path):
|
|
168
158
|
check_path = os.path.join(dirname, filename)
|
|
@@ -182,12 +172,7 @@ def load(
|
|
|
182
172
|
) -> bool:
|
|
183
173
|
"""Parse a dotenv file and then load all the variables found as environment variables."""
|
|
184
174
|
|
|
185
|
-
dotenv = DotEnv(
|
|
186
|
-
filepath=filepath,
|
|
187
|
-
interpolate=interpolate,
|
|
188
|
-
override=override,
|
|
189
|
-
stream=stream,
|
|
190
|
-
)
|
|
175
|
+
dotenv = DotEnv(filepath=filepath, interpolate=interpolate, override=override, stream=stream)
|
|
191
176
|
return dotenv.set_as_environment_variables()
|
|
192
177
|
|
|
193
178
|
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/dotenv/parsers.py
RENAMED
|
@@ -7,34 +7,15 @@ import codecs
|
|
|
7
7
|
import dataclasses
|
|
8
8
|
|
|
9
9
|
from typing import IO
|
|
10
|
-
from typing import NamedTuple
|
|
11
10
|
from typing import TYPE_CHECKING
|
|
12
11
|
|
|
12
|
+
from poetry_plugin_dotenv.exceptions import PoetryPluginDotenvPatternError
|
|
13
|
+
|
|
13
14
|
|
|
14
15
|
if TYPE_CHECKING: # pragma: no cover
|
|
15
16
|
from collections.abc import Iterator
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
class Original(NamedTuple):
|
|
19
|
-
"""Position of the original string in the file."""
|
|
20
|
-
|
|
21
|
-
string: str
|
|
22
|
-
line: int
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Binding(NamedTuple):
|
|
26
|
-
"""Binding of a key and a value."""
|
|
27
|
-
|
|
28
|
-
key: str | None
|
|
29
|
-
value: str | None
|
|
30
|
-
original: Original
|
|
31
|
-
error: bool
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class DotenvParseError(Exception):
|
|
35
|
-
"""Exception for dotenv parse errors."""
|
|
36
|
-
|
|
37
|
-
|
|
38
19
|
def make_regex(string: str, extra_flags: int = 0) -> re.Pattern[str]:
|
|
39
20
|
"""Construct a regex expression."""
|
|
40
21
|
|
|
@@ -58,6 +39,24 @@ _double_quote_escapes = make_regex(r"\\[\\'\"abfnrtv]")
|
|
|
58
39
|
_single_quote_escapes = make_regex(r"\\[\\']")
|
|
59
40
|
|
|
60
41
|
|
|
42
|
+
@dataclasses.dataclass(frozen=True)
|
|
43
|
+
class Original:
|
|
44
|
+
"""Position of the original string in the file."""
|
|
45
|
+
|
|
46
|
+
string: str
|
|
47
|
+
line: int
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclasses.dataclass(frozen=True)
|
|
51
|
+
class Binding:
|
|
52
|
+
"""Binding of a key and a value."""
|
|
53
|
+
|
|
54
|
+
key: str | None
|
|
55
|
+
value: str | None
|
|
56
|
+
original: Original
|
|
57
|
+
error: bool
|
|
58
|
+
|
|
59
|
+
|
|
61
60
|
@dataclasses.dataclass
|
|
62
61
|
class Position:
|
|
63
62
|
"""Model of a cursor position."""
|
|
@@ -107,19 +106,15 @@ class Reader:
|
|
|
107
106
|
def get_marked(self) -> Original:
|
|
108
107
|
"""Get a mark."""
|
|
109
108
|
|
|
110
|
-
# fmt: off
|
|
111
109
|
return Original(
|
|
112
|
-
string=self.string[self.mark.chars: self.position.chars],
|
|
110
|
+
string=self.string[self.mark.chars : self.position.chars],
|
|
113
111
|
line=self.mark.line,
|
|
114
112
|
)
|
|
115
|
-
# fmt: on
|
|
116
113
|
|
|
117
114
|
def peek(self, count: int) -> str:
|
|
118
115
|
"""Peek a dotenv."""
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
return self.string[self.position.chars: self.position.chars + count]
|
|
122
|
-
# fmt: on
|
|
117
|
+
return self.string[self.position.chars : self.position.chars + count]
|
|
123
118
|
|
|
124
119
|
def read_regex(self, regex: re.Pattern[str]) -> tuple[str, ...]:
|
|
125
120
|
"""Read a dotenv with a regex."""
|
|
@@ -128,11 +123,9 @@ class Reader:
|
|
|
128
123
|
|
|
129
124
|
if match is None:
|
|
130
125
|
msg = "Pattern not found."
|
|
131
|
-
raise
|
|
126
|
+
raise PoetryPluginDotenvPatternError(msg)
|
|
132
127
|
|
|
133
|
-
|
|
134
|
-
matched = self.string[match.start(): match.end()]
|
|
135
|
-
# fmt: on
|
|
128
|
+
matched = self.string[match.start() : match.end()]
|
|
136
129
|
|
|
137
130
|
self.position.advance(matched)
|
|
138
131
|
return match.groups()
|
|
@@ -158,11 +151,11 @@ def parse_key(reader: Reader) -> str | None:
|
|
|
158
151
|
if char == "#":
|
|
159
152
|
return None
|
|
160
153
|
|
|
161
|
-
|
|
162
|
-
key,
|
|
154
|
+
if char == "'":
|
|
155
|
+
(key,) = reader.read_regex(_single_quoted_key)
|
|
163
156
|
|
|
164
157
|
else:
|
|
165
|
-
key,
|
|
158
|
+
(key,) = reader.read_regex(_unquoted_key)
|
|
166
159
|
|
|
167
160
|
return key
|
|
168
161
|
|
|
@@ -170,7 +163,7 @@ def parse_key(reader: Reader) -> str | None:
|
|
|
170
163
|
def parse_unquoted_value(reader: Reader) -> str:
|
|
171
164
|
"""Parse an unquoted dotenv value."""
|
|
172
165
|
|
|
173
|
-
part,
|
|
166
|
+
(part,) = reader.read_regex(_unquoted_value)
|
|
174
167
|
return re.sub(r"\s+#.*", "", part).rstrip()
|
|
175
168
|
|
|
176
169
|
|
|
@@ -180,14 +173,14 @@ def parse_value(reader: Reader) -> str:
|
|
|
180
173
|
char = reader.peek(1)
|
|
181
174
|
|
|
182
175
|
if char == "'":
|
|
183
|
-
value,
|
|
176
|
+
(value,) = reader.read_regex(_single_quoted_value)
|
|
184
177
|
return decode_escapes(_single_quote_escapes, value)
|
|
185
178
|
|
|
186
|
-
|
|
187
|
-
value,
|
|
179
|
+
if char == '"':
|
|
180
|
+
(value,) = reader.read_regex(_double_quoted_value)
|
|
188
181
|
return decode_escapes(_double_quote_escapes, value)
|
|
189
182
|
|
|
190
|
-
|
|
183
|
+
if char in {"", "\n", "\r"}:
|
|
191
184
|
return ""
|
|
192
185
|
|
|
193
186
|
return parse_unquoted_value(reader)
|
|
@@ -230,7 +223,7 @@ def parse_binding(reader: Reader) -> Binding:
|
|
|
230
223
|
error=False,
|
|
231
224
|
)
|
|
232
225
|
|
|
233
|
-
except
|
|
226
|
+
except PoetryPluginDotenvPatternError:
|
|
234
227
|
reader.read_regex(_rest_of_line)
|
|
235
228
|
return Binding(
|
|
236
229
|
key=None,
|
|
@@ -48,20 +48,20 @@ class Variable:
|
|
|
48
48
|
def resolve(self, env: OrderedDict[str, str], *args, **kwargs) -> str: # type: ignore[no-untyped-def]
|
|
49
49
|
"""Get a variable value."""
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
env_val = env.get(self.name, default)
|
|
53
|
-
return env_val if env_val else ""
|
|
51
|
+
return env.get(self.name, self.default) or "" # type: ignore[arg-type]
|
|
54
52
|
|
|
55
53
|
|
|
56
54
|
def parse(value: str) -> Iterator[Literal | Variable]:
|
|
57
55
|
"""Parse values."""
|
|
58
56
|
|
|
59
57
|
cursor = 0
|
|
58
|
+
value_length = len(value)
|
|
59
|
+
matches = list(_posix_variable.finditer(value))
|
|
60
60
|
|
|
61
|
-
for match in
|
|
61
|
+
for match in matches:
|
|
62
62
|
start, end = match.span()
|
|
63
|
-
name = match.
|
|
64
|
-
default = match.
|
|
63
|
+
name = match.group("name")
|
|
64
|
+
default = match.group("default")
|
|
65
65
|
|
|
66
66
|
if start > cursor:
|
|
67
67
|
yield Literal(value=value[cursor:start])
|
|
@@ -69,6 +69,5 @@ def parse(value: str) -> Iterator[Literal | Variable]:
|
|
|
69
69
|
yield Variable(name=name, default=default)
|
|
70
70
|
cursor = end
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
yield Literal(value=value[cursor:length])
|
|
72
|
+
if cursor < value_length:
|
|
73
|
+
yield Literal(value=value[cursor:])
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Module defines custom exceptions that are used across plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PoetryPluginDotenvError(Exception):
|
|
7
|
+
"""Base exception."""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PoetryPluginDotenvPatternError(PoetryPluginDotenvError):
|
|
11
|
+
"""Exception raised when a dotenv pattern is not valid or not found."""
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/logger.py
RENAMED
|
@@ -14,13 +14,13 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
14
14
|
from cleo.events.console_command_event import ConsoleCommandEvent
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
class Style(enum.Enum):
|
|
17
|
+
class Style(enum.Enum):
|
|
18
18
|
"""Style tags to color text output."""
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
INFO = "<info>{0!s}</info>"
|
|
21
|
+
DEBUG = "<debug>{0!s}</debug>"
|
|
22
|
+
WARNING = "<warning>{0!s}</warning>"
|
|
23
|
+
ERROR = "<error>{0!s}</error>"
|
|
24
24
|
|
|
25
25
|
def __call__(self, text: str) -> str:
|
|
26
26
|
"""Apply a style to the text."""
|
|
@@ -28,8 +28,8 @@ class Style(enum.Enum): # pragma: no cover
|
|
|
28
28
|
return self.value.format(text)
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
class Logger:
|
|
32
|
-
"""Logger
|
|
31
|
+
class Logger:
|
|
32
|
+
"""Logger for the ``poetry`` events.
|
|
33
33
|
|
|
34
34
|
Notes
|
|
35
35
|
-----
|
|
@@ -41,25 +41,29 @@ class Logger: # pragma: no cover
|
|
|
41
41
|
def __init__(self, event: ConsoleCommandEvent) -> None:
|
|
42
42
|
"""Initialize."""
|
|
43
43
|
|
|
44
|
-
self.event = event
|
|
45
44
|
self.write_line = partial(event.io.write_line, verbosity=Verbosity.DEBUG)
|
|
46
45
|
|
|
47
46
|
def info(self, msg: str) -> None:
|
|
48
|
-
"""Log
|
|
47
|
+
"""Log an info message."""
|
|
49
48
|
|
|
50
|
-
self.
|
|
49
|
+
self._log(Style.INFO, msg)
|
|
51
50
|
|
|
52
51
|
def debug(self, msg: str) -> None:
|
|
53
52
|
"""Log a debug message."""
|
|
54
53
|
|
|
55
|
-
self.
|
|
54
|
+
self._log(Style.DEBUG, msg) # pragma: nocover
|
|
56
55
|
|
|
57
56
|
def warning(self, msg: str) -> None:
|
|
58
57
|
"""Log a warning message."""
|
|
59
58
|
|
|
60
|
-
self.
|
|
59
|
+
self._log(Style.WARNING, msg)
|
|
61
60
|
|
|
62
61
|
def error(self, msg: str) -> None:
|
|
63
|
-
"""Log
|
|
62
|
+
"""Log an error message."""
|
|
64
63
|
|
|
65
|
-
self.
|
|
64
|
+
self._log(Style.ERROR, msg)
|
|
65
|
+
|
|
66
|
+
def _log(self, style: Style, msg: str) -> None:
|
|
67
|
+
"""Log a message with the given style."""
|
|
68
|
+
|
|
69
|
+
self.write_line(style(msg))
|
{poetry_plugin_dotenv-2.2.3 → poetry_plugin_dotenv-2.3.0}/src/poetry_plugin_dotenv/plugin.py
RENAMED
|
@@ -33,36 +33,37 @@ class DotenvPlugin(ApplicationPlugin):
|
|
|
33
33
|
application.event_dispatcher.add_listener(COMMAND, listener=self.load) # type: ignore[union-attr, arg-type]
|
|
34
34
|
|
|
35
35
|
def load(self, event: ConsoleCommandEvent, *args, **kwargs) -> None: # type: ignore[no-untyped-def]
|
|
36
|
-
"""Load a dotenv file."""
|
|
36
|
+
"""Load a dotenv file based on the provided configuration."""
|
|
37
37
|
|
|
38
|
-
working_dir
|
|
39
|
-
working_dir = working_dir if working_dir else os.path.curdir
|
|
40
|
-
|
|
41
|
-
is_env_command = isinstance(event.command, EnvCommand)
|
|
38
|
+
working_dir = event.io.input.option("directory") or os.path.curdir
|
|
42
39
|
|
|
43
40
|
logger = Logger(event)
|
|
44
41
|
config = Config(working_dir)
|
|
45
42
|
|
|
46
|
-
if
|
|
43
|
+
if not isinstance(event.command, EnvCommand):
|
|
44
|
+
return # pragma: nocover
|
|
45
|
+
|
|
46
|
+
if config.ignore:
|
|
47
47
|
logger.warning("Not loading environment variables.")
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
filepath = self._determine_filepath(config, working_dir)
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if os.path.isfile(filepath):
|
|
53
|
+
logger.info(f"Loading environment variables from '{filepath}'.")
|
|
54
|
+
dotenv.core.load(filepath)
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
os.path.join(working_dir, config.location)
|
|
56
|
-
if working_dir != "."
|
|
57
|
-
else config.location
|
|
58
|
-
)
|
|
56
|
+
else:
|
|
57
|
+
logger.error(f"File '{filepath}' doesn't exist.")
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
def _determine_filepath(self, config: Config, working_dir: str) -> str:
|
|
60
|
+
"""Determine the appropriate filepath for the dotenv file."""
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
if config.location:
|
|
63
|
+
return (
|
|
64
|
+
os.path.abspath(config.location)
|
|
65
|
+
if os.path.isabs(config.location)
|
|
66
|
+
else os.path.join(working_dir, config.location)
|
|
67
|
+
)
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
logger.error(f"File '{filepath}' doesn't exist.")
|
|
69
|
+
return dotenv.core.find(usecwd=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|