Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/config.py @ 405:af367e1d0950
Allow to rebind a jailed configuration to another "similar" base
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Fri, 19 Nov 2021 13:26:53 +0100 |
| parents | 6a5aea02f3d0 |
| children | 5286df5aeefe |
line wrap: on
line diff
--- a/configmix/config.py Fri Nov 19 12:40:23 2021 +0100 +++ b/configmix/config.py Fri Nov 19 13:26:53 2021 +0100 @@ -716,7 +716,6 @@ def __init__(self, config, *path): super(_JailedConfiguration, self).__init__() - self._base = config self._path = path if path: self._pathstr = \ @@ -725,12 +724,26 @@ + Configuration._HIER_SEPARATOR else: self._pathstr = '' + self.rebind(config) + + def rebind(self, new_base): + """Bind the jail to a new unjailed configuration `new_base`. + + The new configuration base also must have an existing path to + the root. + + :param Configuration new_base: the new base + + """ + if new_base.is_jail: + raise TypeError("can only bind to an unjailed configuration") + self._base = new_base # # Early error out if the chroot does not exist but allow # degenerated case if `self._path` is empty. # if self._path: - self._base.getvarl(*self._path) + new_base.getvarl(*self._path) def getvarl(self, *path, **kwds): return self._base.getvarl(*(self._path + path), **kwds)
