summaryrefslogtreecommitdiff
path: root/src/home/config/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/config/config.py')
-rw-r--r--src/home/config/config.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/home/config/config.py b/src/home/config/config.py
index 7d18f99..0c0e944 100644
--- a/src/home/config/config.py
+++ b/src/home/config/config.py
@@ -105,6 +105,19 @@ class ConfigStore:
def __contains__(self, key):
return key in self.data
+ def get(self, key: str, default=None):
+ cur = self.data
+ pts = key.split('.')
+ for i in range(len(pts)):
+ k = pts[i]
+ if i < len(pts)-1:
+ if k not in cur:
+ raise KeyError(f'key {k} not found')
+ else:
+ return cur[k] if k in cur else default
+ cur = self.data[k]
+ raise KeyError(f'option {key} not found')
+
def items(self):
return self.data.items()