diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-11 02:25:41 +0800 |
commit | 0d7dd933dfab91faf1a42b7883eb059d7fb31d80 (patch) | |
tree | 123f1a8e21a0398363f5d22f7169969ce1a483c2 /tools/cru-py/cru/service/_config.py | |
parent | 51842e8b324908bae234eb9049295970a51ef4a7 (diff) | |
download | crupest-0d7dd933dfab91faf1a42b7883eb059d7fb31d80.tar.gz crupest-0d7dd933dfab91faf1a42b7883eb059d7fb31d80.tar.bz2 crupest-0d7dd933dfab91faf1a42b7883eb059d7fb31d80.zip |
HALF WORK: 2024.1.11
Diffstat (limited to 'tools/cru-py/cru/service/_config.py')
-rw-r--r-- | tools/cru-py/cru/service/_config.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/cru-py/cru/service/_config.py b/tools/cru-py/cru/service/_config.py index b5f3e7c..018b45b 100644 --- a/tools/cru-py/cru/service/_config.py +++ b/tools/cru-py/cru/service/_config.py @@ -5,6 +5,7 @@ from cru.value import ( RandomStringValueGenerator, UuidValueGenerator, ) +from cru.parsing import SimpleLineConfigParser from ._base import AppFeaturePath, AppFeatureProvider, OWNER_NAME @@ -83,7 +84,7 @@ class ConfigManager(AppFeatureProvider): ) @property - def config_path(self) -> AppFeaturePath: + def config_file_path(self) -> AppFeaturePath: return self._config_path @property @@ -91,5 +92,18 @@ class ConfigManager(AppFeatureProvider): return self._configuration @property + def config_keys(self) -> list[str]: + return [item.name for item in self.configuration] + + @property def config_map(self) -> dict[str, str]: raise NotImplementedError() + + def reload_config_file(self) -> bool: + self.configuration.reset_all() + if not self.config_file_path.check_self(): + return False + parser = SimpleLineConfigParser() + parse_result = parser.parse(self.config_file_path.full_path.read_text()) + config_dict = parse_result.cru_iter().group_by(lambda i: i.key) + return True |