diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-15 15:55:51 +0800 |
commit | 7f2e4107e7f469d6747350487e9441d9b987de47 (patch) | |
tree | 245a543316e9f1291acebe0aefd510e7064e92a2 /tools/cru-py/cru/config.py | |
parent | a5c2f62b0b3c4ec6ce46c57bcd99319a85900798 (diff) | |
download | crupest-7f2e4107e7f469d6747350487e9441d9b987de47.tar.gz crupest-7f2e4107e7f469d6747350487e9441d9b987de47.tar.bz2 crupest-7f2e4107e7f469d6747350487e9441d9b987de47.zip |
HALF WORK: 2024.1.15
Diffstat (limited to 'tools/cru-py/cru/config.py')
-rw-r--r-- | tools/cru-py/cru/config.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/cru-py/cru/config.py b/tools/cru-py/cru/config.py index bd8eaf9..b71f042 100644 --- a/tools/cru-py/cru/config.py +++ b/tools/cru-py/cru/config.py @@ -161,3 +161,18 @@ class Configuration(CruUniqueKeyList[ConfigItem[Any], str]): return { item.name: item.value_type.convert_value_to_str(item.value) for item in self } + + def set_value_dict( + self, + value_dict: dict[str, Any], + *, + empty_is_default: bool = True, + allow_convert_from_str: bool = True, + ) -> None: + for name, value in value_dict.items(): + item = self.get(name) + item.set_value( + value, + empty_is_default=empty_is_default, + allow_convert_from_str=allow_convert_from_str, + ) |