zpp_config 2.2.2__tar.gz → 2.2.3__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.
- {zpp_config-2.2.2/zpp_config.egg-info → zpp_config-2.2.3}/PKG-INFO +8 -1
- {zpp_config-2.2.2 → zpp_config-2.2.3}/README.md +7 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/config.py +23 -2
- {zpp_config-2.2.2 → zpp_config-2.2.3/zpp_config.egg-info}/PKG-INFO +8 -1
- {zpp_config-2.2.2 → zpp_config-2.2.3}/LICENSE +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/setup.cfg +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/tests/test_access.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/tests/test_backends.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/tests/test_merge_update_delete.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/tests/test_validation.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/__init__.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/__init__.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/cfg.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/global_backend.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/ini.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/json.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/toml.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/backend/yaml.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/cli.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/core/__init__.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/core/autoreload.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/core/logs.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/core/vault.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config/core/vault_encryption.py +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config.egg-info/SOURCES.txt +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config.egg-info/dependency_links.txt +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config.egg-info/entry_points.txt +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config.egg-info/requires.txt +0 -0
- {zpp_config-2.2.2 → zpp_config-2.2.3}/zpp_config.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zpp_config
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.3
|
|
4
4
|
Summary: Module pour le chargement et la modification de fichier de configuration
|
|
5
5
|
Home-page: https://github.com/ZephyrOff/zpp_config
|
|
6
6
|
Author:
|
|
@@ -71,10 +71,15 @@ Le backend est automatiquement choisi selon l’extension du fichier, mais il es
|
|
|
71
71
|
Lors de l'initialisation, il est également possible de définir plusieurs paramètres qui seront utile pour le render Jinja.
|
|
72
72
|
|
|
73
73
|
**context**: défini un dictionnaire contenant les variables Jinja
|
|
74
|
+
|
|
74
75
|
**vault_file**: emplacement du fichier vault
|
|
76
|
+
|
|
75
77
|
**vault_keyfile**: emplacement du fichier contenant le mot de passe du vault
|
|
78
|
+
|
|
76
79
|
**vault_password**: mot de passe du vault
|
|
80
|
+
|
|
77
81
|
**vault_encryption_keyfile**: emplacement du fichier contenant le mot de passe du vault_encryption
|
|
82
|
+
|
|
78
83
|
**vault_encryption_password**: mot de passe du vault_encryption
|
|
79
84
|
|
|
80
85
|
```python
|
|
@@ -144,6 +149,8 @@ db_host = config["db.host"]
|
|
|
144
149
|
```python
|
|
145
150
|
db_host = config.get("db.host", default="127.0.0.1")
|
|
146
151
|
```
|
|
152
|
+
Par défaut, la méthode get va renvoyer un ConfigNode, mais il est possible de forcer l'envoi d'un dict brut avec dict_strict=True
|
|
153
|
+
|
|
147
154
|
#### Itération
|
|
148
155
|
```python
|
|
149
156
|
for key, sub in config.db.items():
|
|
@@ -32,10 +32,15 @@ Le backend est automatiquement choisi selon l’extension du fichier, mais il es
|
|
|
32
32
|
Lors de l'initialisation, il est également possible de définir plusieurs paramètres qui seront utile pour le render Jinja.
|
|
33
33
|
|
|
34
34
|
**context**: défini un dictionnaire contenant les variables Jinja
|
|
35
|
+
|
|
35
36
|
**vault_file**: emplacement du fichier vault
|
|
37
|
+
|
|
36
38
|
**vault_keyfile**: emplacement du fichier contenant le mot de passe du vault
|
|
39
|
+
|
|
37
40
|
**vault_password**: mot de passe du vault
|
|
41
|
+
|
|
38
42
|
**vault_encryption_keyfile**: emplacement du fichier contenant le mot de passe du vault_encryption
|
|
43
|
+
|
|
39
44
|
**vault_encryption_password**: mot de passe du vault_encryption
|
|
40
45
|
|
|
41
46
|
```python
|
|
@@ -105,6 +110,8 @@ db_host = config["db.host"]
|
|
|
105
110
|
```python
|
|
106
111
|
db_host = config.get("db.host", default="127.0.0.1")
|
|
107
112
|
```
|
|
113
|
+
Par défaut, la méthode get va renvoyer un ConfigNode, mais il est possible de forcer l'envoi d'un dict brut avec dict_strict=True
|
|
114
|
+
|
|
108
115
|
#### Itération
|
|
109
116
|
```python
|
|
110
117
|
for key, sub in config.db.items():
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import impmagic
|
|
2
2
|
from jinja2 import FileSystemLoader
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
import copy
|
|
4
5
|
|
|
5
6
|
class ValidationError(Exception):
|
|
6
7
|
pass
|
|
@@ -111,7 +112,10 @@ class ConfigNode:
|
|
|
111
112
|
val = self._get_value()
|
|
112
113
|
if isinstance(val, dict):
|
|
113
114
|
for k, v in val.items():
|
|
114
|
-
|
|
115
|
+
if isinstance(v, dict):
|
|
116
|
+
yield k, ConfigNode(self._config or self, self._full_path(k))
|
|
117
|
+
else:
|
|
118
|
+
yield k, v
|
|
115
119
|
|
|
116
120
|
def keys(self):
|
|
117
121
|
# autoload
|
|
@@ -129,7 +133,7 @@ class ConfigNode:
|
|
|
129
133
|
for k in val:
|
|
130
134
|
yield ConfigNode(self._config or self, f"{self._full_path(k)}")
|
|
131
135
|
|
|
132
|
-
def get(self, path, default=None, strict
|
|
136
|
+
def get(self, path, default=None, strict=False, dict_strict=False):
|
|
133
137
|
# autoload
|
|
134
138
|
object.__getattribute__(self, "_autoload")()
|
|
135
139
|
|
|
@@ -141,6 +145,11 @@ class ConfigNode:
|
|
|
141
145
|
raise KeyError(path)
|
|
142
146
|
return default
|
|
143
147
|
node = node[k]
|
|
148
|
+
|
|
149
|
+
if not dict_strict:
|
|
150
|
+
if isinstance(node, dict):
|
|
151
|
+
return ConfigNode(self._config or self, self._full_path(path))
|
|
152
|
+
|
|
144
153
|
return node
|
|
145
154
|
|
|
146
155
|
def set(self, path, value):
|
|
@@ -350,6 +359,18 @@ class ConfigNode:
|
|
|
350
359
|
|
|
351
360
|
self.delete(path)
|
|
352
361
|
|
|
362
|
+
def __len__(self):
|
|
363
|
+
object.__getattribute__(self, "_autoload")()
|
|
364
|
+
|
|
365
|
+
val = self._get_value()
|
|
366
|
+
return len(val) if isinstance(val, dict) else 0
|
|
367
|
+
|
|
368
|
+
def copy(self):
|
|
369
|
+
object.__getattribute__(self, "_autoload")()
|
|
370
|
+
|
|
371
|
+
data = copy.deepcopy(self.to_dict())
|
|
372
|
+
return ConfigNode(config=None, path="", _data=data)
|
|
373
|
+
|
|
353
374
|
|
|
354
375
|
class Config(ConfigNode):
|
|
355
376
|
@impmagic.loader(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: zpp_config
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.3
|
|
4
4
|
Summary: Module pour le chargement et la modification de fichier de configuration
|
|
5
5
|
Home-page: https://github.com/ZephyrOff/zpp_config
|
|
6
6
|
Author:
|
|
@@ -71,10 +71,15 @@ Le backend est automatiquement choisi selon l’extension du fichier, mais il es
|
|
|
71
71
|
Lors de l'initialisation, il est également possible de définir plusieurs paramètres qui seront utile pour le render Jinja.
|
|
72
72
|
|
|
73
73
|
**context**: défini un dictionnaire contenant les variables Jinja
|
|
74
|
+
|
|
74
75
|
**vault_file**: emplacement du fichier vault
|
|
76
|
+
|
|
75
77
|
**vault_keyfile**: emplacement du fichier contenant le mot de passe du vault
|
|
78
|
+
|
|
76
79
|
**vault_password**: mot de passe du vault
|
|
80
|
+
|
|
77
81
|
**vault_encryption_keyfile**: emplacement du fichier contenant le mot de passe du vault_encryption
|
|
82
|
+
|
|
78
83
|
**vault_encryption_password**: mot de passe du vault_encryption
|
|
79
84
|
|
|
80
85
|
```python
|
|
@@ -144,6 +149,8 @@ db_host = config["db.host"]
|
|
|
144
149
|
```python
|
|
145
150
|
db_host = config.get("db.host", default="127.0.0.1")
|
|
146
151
|
```
|
|
152
|
+
Par défaut, la méthode get va renvoyer un ConfigNode, mais il est possible de forcer l'envoi d'un dict brut avec dict_strict=True
|
|
153
|
+
|
|
147
154
|
#### Itération
|
|
148
155
|
```python
|
|
149
156
|
for key, sub in config.db.items():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|