diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-02-19 02:12:17 +0800 | 
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-02-19 02:42:56 +0800 | 
| commit | c93dfd784038393e24d74ef8c7b8e3e142cc025d (patch) | |
| tree | 6fad418acfeb45123c446326aeacef1a09d59a84 | |
| parent | b524986daf378cfe7aeafddafa98e9f978d26729 (diff) | |
| download | crupest-c93dfd784038393e24d74ef8c7b8e3e142cc025d.tar.gz crupest-c93dfd784038393e24d74ef8c7b8e3e142cc025d.tar.bz2 crupest-c93dfd784038393e24d74ef8c7b8e3e142cc025d.zip | |
fix(cru-py): config item.
| -rw-r--r-- | tools/cru-py/cru/list.py | 2 | ||||
| -rw-r--r-- | tools/cru-py/cru/service/_config.py | 11 | 
2 files changed, 7 insertions, 6 deletions
| diff --git a/tools/cru-py/cru/list.py b/tools/cru-py/cru/list.py index 9d210b7..216a561 100644 --- a/tools/cru-py/cru/list.py +++ b/tools/cru-py/cru/list.py @@ -97,7 +97,7 @@ class CruUniqueKeyList(Generic[_T, _K]):      def get(self, key: _K) -> _T:          value = self.get_or(key) -        if value is CruNotFound: +        if value is CruNotFound.VALUE:              raise KeyError(f"Key {key} not found!")          return value  # type: ignore diff --git a/tools/cru-py/cru/service/_config.py b/tools/cru-py/cru/service/_config.py index 6aa6294..cbb9533 100644 --- a/tools/cru-py/cru/service/_config.py +++ b/tools/cru-py/cru/service/_config.py @@ -1,7 +1,7 @@  from collections.abc import Iterable  from typing import Any, Literal, overload -from cru import CruException +from cru import CruException, CruNotFound  from cru.config import Configuration, ConfigItem  from cru.value import (      INTEGER_VALUE_TYPE, @@ -360,14 +360,15 @@ class ConfigManager(AppCommandFeatureProvider):          error_entries: list[SimpleLineConfigParser.Entry] = []          errors: list[CruValueTypeError] = []          for key, entry in entry_dict.items(): -            config_item = self.configuration.get(key)              try:                  if entry.value == "":                      value_dict[key] = None                  else: -                    value_dict[key] = config_item.value_type.convert_str_to_value( -                        entry.value -                    ) +                    value = entry.value +                    config_item = self.configuration.get_or(key) +                    if config_item is not CruNotFound.VALUE: +                        value = config_item.value_type.convert_str_to_value(value) +                    value_dict[key] = value              except CruValueTypeError as e:                  error_entries.append(entry)                  errors.append(e) | 
