Load to existing config
This commit is contained in:
parent
ae1bbc63e7
commit
9d20aaa394
1 changed files with 4 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from dataclasses import dataclass, field
|
||||
from enum import Enum, auto
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar
|
||||
|
||||
__all__ = ["ConfigException", "ConfigValueException", "TransparentConfig",
|
||||
"Kind", "Condition", "Option", "TreeLoader"]
|
||||
|
|
@ -78,6 +78,8 @@ class Option:
|
|||
if not condition(value):
|
||||
raise ConfigValueException(error_message)
|
||||
|
||||
T = TypeVar("T", bound=TransparentConfig)
|
||||
|
||||
class TreeLoader:
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
|
@ -94,8 +96,7 @@ class TreeLoader:
|
|||
|
||||
return config
|
||||
|
||||
def load(self, data: Any) -> TransparentConfig:
|
||||
config = TransparentConfig()
|
||||
def load_to(self, config: T, data: Any) -> T:
|
||||
errors = []
|
||||
|
||||
for name, option in self._options.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue