This commit is contained in:
superobk
2024-05-16 16:09:25 +08:00
2 changed files with 10 additions and 4 deletions

View File

@ -36,6 +36,13 @@ class Configuration():
if length == 0 or not isinstance(cfg, dict):
return None
if length == 1:
return self.get(path.split("."), cfg, default=default)
lenght = len(path)
if lenght == 0 or not isinstance(cfg, dict):
if default is None:
return None
return default
if lenght == 1:
return cfg.get(path[0])
return self.get(path[1:], cfg.get(path[0]), default=default)
@ -87,4 +94,4 @@ class EnvConf():
@inject
def __init__(self, config: Configuration) -> None:
self.version = config.get("env.version")
self.version = config.get("env.version")