Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/config.py @ 756:cabd1046d95f
Extract new config methods extract_new_config
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 04 Dec 2023 09:20:30 +0100 |
| parents | 75d37575472b |
| children | 3eb2c451026b |
line wrap: on
line diff
--- a/configmix/config.py Thu Nov 30 21:11:47 2023 +0100 +++ b/configmix/config.py Mon Dec 04 09:20:30 2023 +0100 @@ -22,6 +22,7 @@ from ordereddict import OrderedDict as ConfigurationBase except ImportError: ConfigurationBase = dict +import copy try: from urllib.parse import urlsplit except ImportError: @@ -1180,6 +1181,15 @@ """ return self.jailed(rootpath=rootpath, root=root).iter_jailed() + def extract_new_config(self, *path, **kwds): + """Get the value at `path` and make a new :class:`~.Configuration` from it. + + The new config is a deepcopy and completely independent of the source + configuration. + + """ + return self.__class__(copy.deepcopy(self.getvarl(*path, **kwds))) + class _JailedConfiguration(CoercingMethodsMixin):
