Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/config.py @ 437:bbc5b64e137a
- Dict-level access to a configuration key now does variable interpolation.
- Basic dict-level access for jailed configurations
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 10 Dec 2021 01:33:37 +0100 |
| parents | b96f49c9c76b |
| children | 37424d1f8dcf |
line wrap: on
line diff
--- a/configmix/config.py Fri Dec 10 01:05:34 2021 +0100 +++ b/configmix/config.py Fri Dec 10 01:33:37 2021 +0100 @@ -238,6 +238,15 @@ is_jail = False """Flag to show that this is not a jail for another configuration""" + def __getitem__(self, key): + """Mapping interface that forwards to :meth:`~.getvarl_s` + + """ + if isinstance(key, (tuple, list)): + return self.getvarl_s(*key) + else: + return self.getvarl_s(key) + def getvarl(self, *path, **kwds): """Get a variable where the hierarchy is given in `path` as sequence and the namespace is given in the `namespace` keyword argument. @@ -513,7 +522,8 @@ if not path: return self try: - v = self.expand_if_reference(self[path[0]]) + # v = self.expand_if_reference(self[path[0]]) + v = self.expand_if_reference(super(Configuration, self).__getitem__(path[0])) for p in path[1:]: v = self.expand_if_reference(v[p]) except TypeError: @@ -808,6 +818,15 @@ if self._path: new_base.getvarl(*self._path) + def __getitem__(self, key): + """Mapping interface that forwards to :meth:`~.getvarl_s` + + """ + if isinstance(key, (tuple, list)): + return self.getvarl_s(*key) + else: + return self.getvarl_s(key) + def getvarl(self, *path, **kwds): return self._base.getvarl(*(self._path + path), **kwds)
