mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
confi.get
This commit is contained in:
@ -27,17 +27,17 @@ class Configuration():
|
||||
bbb:
|
||||
ccc: "hello world"
|
||||
"""
|
||||
def get(self, path: str | list[str], cfg: dict = None, default = None):
|
||||
def get(self, path: str | list[str], cfg: dict = None, default=None):
|
||||
if isinstance(path, str):
|
||||
if cfg is None:
|
||||
cfg = self.cfg
|
||||
return self.get(path.split("."), cfg)
|
||||
length = len(path)
|
||||
if length == 0 or not isinstance(cfg, dict):
|
||||
return None
|
||||
return default
|
||||
if length == 1:
|
||||
return cfg.get(path[0])
|
||||
return self.get(path[1:], cfg.get(path[0]), default=default)
|
||||
return self.get(path[1:], cfg.get(path[0]))
|
||||
|
||||
class TesouConf():
|
||||
url: str
|
||||
|
||||
Reference in New Issue
Block a user