diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-06-08 20:41:09 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-06-08 20:41:09 +0300 |
commit | 80913481b95bbf78355efa8ba0f2aac51a11c2f6 (patch) | |
tree | 3ecad809e0f13754ee39d22bc783a88fdf5dd05f | |
parent | eed52f7620cebd9729d24743aca6cfdaf997ab89 (diff) |
wip
-rw-r--r-- | src/home/config/config.py | 4 | ||||
-rw-r--r-- | src/home/config/validators/__init__.py | 1 | ||||
-rw-r--r-- | src/home/config/validators/_util.py | 11 | ||||
-rwxr-xr-x | src/test_new_config.py | 4 |
4 files changed, 4 insertions, 16 deletions
diff --git a/src/home/config/config.py b/src/home/config/config.py index d526bb2..5305039 100644 --- a/src/home/config/config.py +++ b/src/home/config/config.py @@ -118,9 +118,9 @@ class ConfigUnit: else: v = Validator(schema) result = v.validate(self._data) - # pprint(self._data) + # pprint.pprint(self._data) if not result: - # pprint(v.errors) + # pprint.pprint(v.errors) raise DocumentError(f'{self.__class__.__name__}: failed to validate data:\n{pprint.pformat(v.errors)}') try: self.custom_validator(self._data) diff --git a/src/home/config/validators/__init__.py b/src/home/config/validators/__init__.py deleted file mode 100644 index 80259d6..0000000 --- a/src/home/config/validators/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._util import validate diff --git a/src/home/config/validators/_util.py b/src/home/config/validators/_util.py deleted file mode 100644 index 5227c40..0000000 --- a/src/home/config/validators/_util.py +++ /dev/null @@ -1,11 +0,0 @@ -import inspect - -from cerberus import Validator, DocumentError - - -def validate(schema, data): - v = Validator(schema) - if not v.validate(data): - frame = inspect.currentframe().f_back - caller_name = frame.f_code.co_name - raise DocumentError(f'{caller_name}: failed to validate data: ' + v.errors) diff --git a/src/test_new_config.py b/src/test_new_config.py index 939281a..ae89495 100755 --- a/src/test_new_config.py +++ b/src/test_new_config.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from home.config import config, LinuxBoardsConfig, ServicesListConfig -from home.mqtt import MqttConfig, MqttNodesConfig +from home.config import config +from home.mqtt import MqttNodesConfig from pprint import pprint |