python-simpleconf 0.9.2__py3-none-any.whl → 0.9.3a1__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.
- {python_simpleconf-0.9.2.dist-info → python_simpleconf-0.9.3a1.dist-info}/METADATA +22 -25
- python_simpleconf-0.9.3a1.dist-info/RECORD +18 -0
- {python_simpleconf-0.9.2.dist-info → python_simpleconf-0.9.3a1.dist-info}/WHEEL +1 -1
- simpleconf/__init__.py +1 -1
- simpleconf/loaders/__init__.py +3 -1
- simpleconf/loaders/dict.py +1 -1
- simpleconf/loaders/env.py +18 -9
- simpleconf/loaders/ini.py +2 -2
- python_simpleconf-0.9.2.dist-info/RECORD +0 -18
- {python_simpleconf-0.9.2.dist-info → python_simpleconf-0.9.3a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-simpleconf
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.3a1
|
|
4
4
|
Summary: Simple configuration management with python.
|
|
5
|
+
Project-URL: Homepage, https://github.com/pwwang/simpleconf
|
|
6
|
+
Project-URL: Repository, https://github.com/pwwang/simpleconf
|
|
7
|
+
Author-email: pwwang <pwwang@pwwang.com>
|
|
5
8
|
License: MIT
|
|
6
9
|
License-File: LICENSE
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Requires-
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: diot<0.4,>=0.3.3
|
|
12
|
+
Requires-Dist: panpath<0.5,>=0.4.8
|
|
18
13
|
Provides-Extra: all
|
|
14
|
+
Requires-Dist: iniconfig<3,>=2.0; extra == 'all'
|
|
15
|
+
Requires-Dist: python-dotenv<2,>=1.1; extra == 'all'
|
|
16
|
+
Requires-Dist: pyyaml<7,>=6; extra == 'all'
|
|
17
|
+
Requires-Dist: rtoml<0.13,>=0.12; (sys_platform == 'linux') and extra == 'all'
|
|
18
|
+
Requires-Dist: tomli<3,>=2.0; (sys_platform != 'linux') and extra == 'all'
|
|
19
19
|
Provides-Extra: async
|
|
20
|
+
Requires-Dist: aiofiles>=23.0.0; extra == 'async'
|
|
20
21
|
Provides-Extra: env
|
|
22
|
+
Requires-Dist: python-dotenv<2,>=1.1; extra == 'env'
|
|
21
23
|
Provides-Extra: ini
|
|
24
|
+
Requires-Dist: iniconfig<3,>=2.0; extra == 'ini'
|
|
22
25
|
Provides-Extra: jinja2
|
|
26
|
+
Requires-Dist: jinja2<4,>=3.0; extra == 'jinja2'
|
|
23
27
|
Provides-Extra: liquid
|
|
28
|
+
Requires-Dist: liquidpy<0.9,>=0.8; extra == 'liquid'
|
|
24
29
|
Provides-Extra: liquidpy
|
|
30
|
+
Requires-Dist: liquidpy<0.9,>=0.8; extra == 'liquidpy'
|
|
25
31
|
Provides-Extra: toml
|
|
32
|
+
Requires-Dist: rtoml<0.13,>=0.12; (sys_platform == 'linux') and extra == 'toml'
|
|
33
|
+
Requires-Dist: tomli<3,>=2.0; (sys_platform != 'linux') and extra == 'toml'
|
|
26
34
|
Provides-Extra: yaml
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist: diot (>=0.3.3,<0.4.0)
|
|
29
|
-
Requires-Dist: iniconfig (>=2.0,<3.0) ; extra == "ini" or extra == "all"
|
|
30
|
-
Requires-Dist: jinja2 (>=3.0,<4.0) ; extra == "jinja2"
|
|
31
|
-
Requires-Dist: liquidpy (>=0.8,<0.9) ; extra == "liquid" or extra == "liquidpy"
|
|
32
|
-
Requires-Dist: panpath (>=0.4.8,<0.5.0)
|
|
33
|
-
Requires-Dist: python-dotenv (>=1.1,<2.0) ; extra == "env" or extra == "all"
|
|
34
|
-
Requires-Dist: pyyaml (>=6,<7) ; extra == "yaml" or extra == "all"
|
|
35
|
-
Requires-Dist: rtoml (>=0.12,<0.13) ; (sys_platform == "linux") and (extra == "toml" or extra == "all")
|
|
36
|
-
Requires-Dist: tomli (>=2.0,<3.0) ; (sys_platform != "linux") and (extra == "toml" or extra == "all")
|
|
37
|
-
Project-URL: Homepage, https://github.com/pwwang/simpleconf
|
|
38
|
-
Project-URL: Repository, https://github.com/pwwang/simpleconf
|
|
35
|
+
Requires-Dist: pyyaml<7,>=6; extra == 'yaml'
|
|
39
36
|
Description-Content-Type: text/markdown
|
|
40
37
|
|
|
41
38
|
# simpleconf
|
|
@@ -403,4 +400,4 @@ from simpleconf import Config
|
|
|
403
400
|
|
|
404
401
|
conf = Config.load('config.yaml')
|
|
405
402
|
# conf.default.a == 2
|
|
406
|
-
```
|
|
403
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
simpleconf/__init__.py,sha256=V3G4vrJauZva5CUPH--DkZnsBFdLNcpumcK5qu27o24,104
|
|
2
|
+
simpleconf/caster.py,sha256=qHnegp1FZzbUWm-UbCaGjQKN6d9rN1v_0Wa4I_CMEi4,2379
|
|
3
|
+
simpleconf/config.py,sha256=B6h-mgeiyI7op-R-i1C_z0oyc4pt7Tv7zKWgzsDy4xw,17922
|
|
4
|
+
simpleconf/exceptions.py,sha256=Tb7w9gMO2XU4mE-Rc2HAnuHWDUpMzdl39oGVjeAv254,171
|
|
5
|
+
simpleconf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
simpleconf/utils.py,sha256=prO5mN64Ir_7bmNnn6kEh-xZAAYiXTOxpiuFhiw9HpI,6247
|
|
7
|
+
simpleconf/loaders/__init__.py,sha256=HeIlfn-bw6NHpS-r7fQqyGRnTZXdApENSd2cGW9y4VE,5482
|
|
8
|
+
simpleconf/loaders/dict.py,sha256=8Az511i9OLLXosSBMMXiEfiQVScQ5SIqsF6EHlAkKdM,801
|
|
9
|
+
simpleconf/loaders/env.py,sha256=cOYZbHk08MrBjxtNfV8Cv5LHrZg_flzap1lOM3GVdRk,3729
|
|
10
|
+
simpleconf/loaders/ini.py,sha256=a8ahJIzw24SIEnGbZmYNoxo8O1tYi6pG_GrOil0Rcx0,3739
|
|
11
|
+
simpleconf/loaders/json.py,sha256=0NTKB9JidB8vbeODxNYAY8fJP6__znetuIUAClFeNIo,1929
|
|
12
|
+
simpleconf/loaders/osenv.py,sha256=K829KFiHLl3pS8HSCep8JoPVG_d7VRxPAb7SPYFRypg,1779
|
|
13
|
+
simpleconf/loaders/toml.py,sha256=OJCukg_R3zlmas_q_CrdeKUsw8Wj5LoSnkNJ7Flt86w,2525
|
|
14
|
+
simpleconf/loaders/yaml.py,sha256=IoKMaQF5y5HWEjQsnUwL2UvABVj9A-0AmBhn8s7lE54,2146
|
|
15
|
+
python_simpleconf-0.9.3a1.dist-info/METADATA,sha256=l8gY5UovwMiMQpYyK22uuObTeSyQ5QADNu-3mwdZsaM,8949
|
|
16
|
+
python_simpleconf-0.9.3a1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
17
|
+
python_simpleconf-0.9.3a1.dist-info/licenses/LICENSE,sha256=2j7OLS2vXIEshgbSkiCU9RgYJY1M4OBBtO6ECbo7OB8,1056
|
|
18
|
+
python_simpleconf-0.9.3a1.dist-info/RECORD,,
|
simpleconf/__init__.py
CHANGED
simpleconf/loaders/__init__.py
CHANGED
|
@@ -157,4 +157,6 @@ class LiqModifierMixin(LoaderModifierMixin):
|
|
|
157
157
|
def _modifier(self, content: str | bytes) -> str | bytes:
|
|
158
158
|
"""Modify the content of the configuration file before loading"""
|
|
159
159
|
from liquid import Liquid # type: ignore[import]
|
|
160
|
-
|
|
160
|
+
str_content = content.decode() if isinstance(content, bytes) else content
|
|
161
|
+
liq = Liquid(str_content, from_file=False, mode="wild") # type: ignore
|
|
162
|
+
return liq.render()
|
simpleconf/loaders/dict.py
CHANGED
simpleconf/loaders/env.py
CHANGED
|
@@ -45,15 +45,19 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
45
45
|
"""Load the configuration from a .env file"""
|
|
46
46
|
if hasattr(conf, "read"):
|
|
47
47
|
content = conf.read()
|
|
48
|
-
|
|
48
|
+
str_content = content.decode() if isinstance(content, bytes) else content
|
|
49
|
+
sio = io.StringIO(str_content) # type: ignore[arg-type]
|
|
50
|
+
return dotenv.dotenv_values(stream=sio)
|
|
49
51
|
|
|
50
52
|
if not self._exists(conf, ignore_nonexist):
|
|
51
53
|
return {}
|
|
52
54
|
|
|
53
55
|
conf = self.__class__._convert_path(conf)
|
|
54
56
|
content = conf.read_text() # so that cloud paths work
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
modified = self._modifier(content)
|
|
58
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
59
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
60
|
+
return dotenv.dotenv_values(stream=sio)
|
|
57
61
|
|
|
58
62
|
async def a_loading(self, conf, ignore_nonexist):
|
|
59
63
|
"""Asynchronously load the configuration from a .env file"""
|
|
@@ -63,16 +67,21 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
63
67
|
content = await content
|
|
64
68
|
if isinstance(content, bytes):
|
|
65
69
|
content = content.decode()
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
modified = self._modifier(content)
|
|
71
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
72
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
73
|
+
return dotenv.dotenv_values(stream=sio)
|
|
68
74
|
|
|
69
75
|
if not await self._a_exists(conf, ignore_nonexist):
|
|
70
76
|
return {}
|
|
71
77
|
|
|
72
78
|
conf = self.__class__._convert_path(conf)
|
|
73
|
-
|
|
74
|
-
content =
|
|
75
|
-
|
|
79
|
+
# so that cloud paths work
|
|
80
|
+
content = await conf.a_read_text() # type: ignore[attr-defined]
|
|
81
|
+
modified = self._modifier(content)
|
|
82
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
83
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
84
|
+
return dotenv.dotenv_values(stream=sio)
|
|
76
85
|
|
|
77
86
|
@classmethod
|
|
78
87
|
def _convert_with_profiles( # type: ignore[override]
|
|
@@ -89,7 +98,7 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
89
98
|
profile = profile.lower()
|
|
90
99
|
out.setdefault(profile, Diot())[key] = v
|
|
91
100
|
|
|
92
|
-
return cast(out, cls.CASTERS)
|
|
101
|
+
return cast(out, cls.CASTERS or [])
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
class EnvsLoader(NoConvertingPathMixin, EnvLoader): # type: ignore[misc]
|
simpleconf/loaders/ini.py
CHANGED
|
@@ -99,7 +99,7 @@ class IniLoader(Loader, LoaderModifierMixin):
|
|
|
99
99
|
if len(keys) == 0 or keys[0].lower() != "default":
|
|
100
100
|
raise ValueError(f"{pathname}: Only the default section can be loaded.")
|
|
101
101
|
|
|
102
|
-
return cast(Diot(loaded[keys[0]]), cls.CASTERS)
|
|
102
|
+
return cast(Diot(loaded[keys[0]]), cls.CASTERS or [])
|
|
103
103
|
|
|
104
104
|
@classmethod
|
|
105
105
|
def _convert_with_profiles( # type: ignore[override]
|
|
@@ -109,7 +109,7 @@ class IniLoader(Loader, LoaderModifierMixin):
|
|
|
109
109
|
) -> Diot:
|
|
110
110
|
out = Diot()
|
|
111
111
|
for k, v in loaded.items():
|
|
112
|
-
out[k.lower()] = cast(v, cls.CASTERS)
|
|
112
|
+
out[k.lower()] = cast(v, cls.CASTERS or [])
|
|
113
113
|
return out
|
|
114
114
|
|
|
115
115
|
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
simpleconf/__init__.py,sha256=GJQ8HSbUdkFNwFYiYeUy1hCligKG_H4wcM20K1ozAPI,104
|
|
2
|
-
simpleconf/caster.py,sha256=qHnegp1FZzbUWm-UbCaGjQKN6d9rN1v_0Wa4I_CMEi4,2379
|
|
3
|
-
simpleconf/config.py,sha256=B6h-mgeiyI7op-R-i1C_z0oyc4pt7Tv7zKWgzsDy4xw,17922
|
|
4
|
-
simpleconf/exceptions.py,sha256=Tb7w9gMO2XU4mE-Rc2HAnuHWDUpMzdl39oGVjeAv254,171
|
|
5
|
-
simpleconf/loaders/__init__.py,sha256=fM4jQd3JoWkp7NdWr1B3MXQ33ytkFI3YS1o59yhE_U4,5362
|
|
6
|
-
simpleconf/loaders/dict.py,sha256=uGY0ufQFwcEinSUFyNSb96RDgynm6tHW5fcEdc-A0Sc,763
|
|
7
|
-
simpleconf/loaders/env.py,sha256=7jwh3TCxxdmJNROSBcGyb9muNC6BZ-rEGi0tznhHSnM,3132
|
|
8
|
-
simpleconf/loaders/ini.py,sha256=PweI85VoTgN5IA4uQUdYZNKP9r0iCna5hb0smsG7_kg,3727
|
|
9
|
-
simpleconf/loaders/json.py,sha256=0NTKB9JidB8vbeODxNYAY8fJP6__znetuIUAClFeNIo,1929
|
|
10
|
-
simpleconf/loaders/osenv.py,sha256=K829KFiHLl3pS8HSCep8JoPVG_d7VRxPAb7SPYFRypg,1779
|
|
11
|
-
simpleconf/loaders/toml.py,sha256=OJCukg_R3zlmas_q_CrdeKUsw8Wj5LoSnkNJ7Flt86w,2525
|
|
12
|
-
simpleconf/loaders/yaml.py,sha256=IoKMaQF5y5HWEjQsnUwL2UvABVj9A-0AmBhn8s7lE54,2146
|
|
13
|
-
simpleconf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
simpleconf/utils.py,sha256=prO5mN64Ir_7bmNnn6kEh-xZAAYiXTOxpiuFhiw9HpI,6247
|
|
15
|
-
python_simpleconf-0.9.2.dist-info/METADATA,sha256=jJ6HLpeMlhMHxz9cbIWppK7pA8rLX5QQCwSJlxHZtao,9175
|
|
16
|
-
python_simpleconf-0.9.2.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
17
|
-
python_simpleconf-0.9.2.dist-info/licenses/LICENSE,sha256=2j7OLS2vXIEshgbSkiCU9RgYJY1M4OBBtO6ECbo7OB8,1056
|
|
18
|
-
python_simpleconf-0.9.2.dist-info/RECORD,,
|
|
File without changes
|