Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
447034046e | ||
|
|
0770ac0bb4 |
@@ -1,7 +1,7 @@
|
|||||||
# MARK: Project info
|
# MARK: Project info
|
||||||
[project]
|
[project]
|
||||||
name = "corelibs"
|
name = "corelibs"
|
||||||
version = "0.12.2"
|
version = "0.12.3"
|
||||||
description = "Collection of utils for Python scripts"
|
description = "Collection of utils for Python scripts"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ class SettingsLoader:
|
|||||||
try:
|
try:
|
||||||
# load all data as is, validation is done afterwards
|
# load all data as is, validation is done afterwards
|
||||||
settings[config_id] = dict(self.config_parser[config_id])
|
settings[config_id] = dict(self.config_parser[config_id])
|
||||||
|
except KeyError as e:
|
||||||
|
self.__print(
|
||||||
|
f"[!] Cannot read [{config_id}] block in the {self.config_file}: {e}",
|
||||||
|
'CRITICAL', raise_exception=True
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
try:
|
||||||
for key, checks in config_validate.items():
|
for key, checks in config_validate.items():
|
||||||
skip = True
|
skip = True
|
||||||
split_char = self.DEFAULT_ELEMENT_SPLIT_CHAR
|
split_char = self.DEFAULT_ELEMENT_SPLIT_CHAR
|
||||||
@@ -145,7 +152,7 @@ class SettingsLoader:
|
|||||||
]
|
]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
self.__print(
|
self.__print(
|
||||||
f"[!] Cannot read [{config_id}] block in the {self.config_file}: {e}",
|
f"[!] Cannot read [{config_id}] block because the entry [{e}] could not be found",
|
||||||
'CRITICAL', raise_exception=True
|
'CRITICAL', raise_exception=True
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ Dict helpers
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def mask(
|
def mask(
|
||||||
data_set: dict[str, str],
|
data_set: dict[str, str],
|
||||||
mask_keys: list[str] | None = None,
|
mask_keys: list[str] | None = None,
|
||||||
@@ -34,4 +37,22 @@ def mask(
|
|||||||
for key, value in data_set.items()
|
for key, value in data_set.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def set_entry(dict_set: dict[str, Any], key: str, value_set: Any) -> dict[str, Any]:
|
||||||
|
"""
|
||||||
|
set a new entry in the dict set
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
key {str} -- _description_
|
||||||
|
dict_set {dict[str, Any]} -- _description_
|
||||||
|
value_set {Any} -- _description_
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict[str, Any] -- _description_
|
||||||
|
"""
|
||||||
|
if not dict_set.get(key):
|
||||||
|
dict_set[key] = {}
|
||||||
|
dict_set[key] = value_set
|
||||||
|
return dict_set
|
||||||
|
|
||||||
# __END__
|
# __END__
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ def main():
|
|||||||
config_data = sl.load_settings(
|
config_data = sl.load_settings(
|
||||||
config_load,
|
config_load,
|
||||||
{
|
{
|
||||||
|
# "doesnt": ["split:,"],
|
||||||
"foo": ["mandatory:yes"],
|
"foo": ["mandatory:yes"],
|
||||||
"foobar": ["check:int"],
|
"foobar": ["check:int"],
|
||||||
"bar": ["mandatory:yes"],
|
"bar": ["mandatory:yes"],
|
||||||
|
|||||||
Reference in New Issue
Block a user