diff options
author | Devaev Maxim <[email protected]> | 2019-09-11 19:11:19 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-09-11 19:11:19 +0300 |
commit | 2535892723e275a3e31aa318edc788869c643fd0 (patch) | |
tree | c51277d4ef558cc010622cfa8c4e4c06777a8ed1 /kvmd/yamlconf | |
parent | e17889ba426a167804796a830043e59e1941972f (diff) |
changed config hierarchy
Diffstat (limited to 'kvmd/yamlconf')
-rw-r--r-- | kvmd/yamlconf/__init__.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/kvmd/yamlconf/__init__.py b/kvmd/yamlconf/__init__.py index 123dc915..b0bc356f 100644 --- a/kvmd/yamlconf/__init__.py +++ b/kvmd/yamlconf/__init__.py @@ -71,15 +71,16 @@ class Section(dict): dict.__init__(self) self.__meta: Dict[str, Dict[str, Any]] = {} - def _unpack(self, _section: Optional["Section"]=None) -> Dict[str, Any]: - if _section is None: - _section = self + def _unpack(self, ignore: Optional[List[str]]=None) -> Dict[str, Any]: + if ignore is None: + ignore = [] unpacked: Dict[str, Any] = {} - for (key, value) in _section.items(): - if isinstance(value, Section): - unpacked[key] = value._unpack() # pylint: disable=protected-access - else: # Option - unpacked[_section._get_unpack_as(key)] = value # pylint: disable=protected-access + for (key, value) in self.items(): + if key not in ignore: + if isinstance(value, Section): + unpacked[key] = value._unpack() # pylint: disable=protected-access + else: # Option + unpacked[self._get_unpack_as(key)] = value # pylint: disable=protected-access return unpacked def _set_meta(self, key: str, default: Any, unpack_as: str, help: str) -> None: # pylint: disable=redefined-builtin |