summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-06-08 20:41:09 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-06-08 20:41:09 +0300
commit80913481b95bbf78355efa8ba0f2aac51a11c2f6 (patch)
tree3ecad809e0f13754ee39d22bc783a88fdf5dd05f
parenteed52f7620cebd9729d24743aca6cfdaf997ab89 (diff)
wip
-rw-r--r--src/home/config/config.py4
-rw-r--r--src/home/config/validators/__init__.py1
-rw-r--r--src/home/config/validators/_util.py11
-rwxr-xr-xsrc/test_new_config.py4
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