Mercurial > hgrepos > Python > libs > ConfigMix
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 755:04c5a3a36499 | 756:cabd1046d95f |
|---|---|
| 20 except ImportError: | 20 except ImportError: |
| 21 try: | 21 try: |
| 22 from ordereddict import OrderedDict as ConfigurationBase | 22 from ordereddict import OrderedDict as ConfigurationBase |
| 23 except ImportError: | 23 except ImportError: |
| 24 ConfigurationBase = dict | 24 ConfigurationBase = dict |
| 25 import copy | |
| 25 try: | 26 try: |
| 26 from urllib.parse import urlsplit | 27 from urllib.parse import urlsplit |
| 27 except ImportError: | 28 except ImportError: |
| 28 from urlparse import urlsplit | 29 from urlparse import urlsplit |
| 29 | 30 |
| 1178 `rootpath` or `root` must refer to a `list` or `dict` container. | 1179 `rootpath` or `root` must refer to a `list` or `dict` container. |
| 1179 | 1180 |
| 1180 """ | 1181 """ |
| 1181 return self.jailed(rootpath=rootpath, root=root).iter_jailed() | 1182 return self.jailed(rootpath=rootpath, root=root).iter_jailed() |
| 1182 | 1183 |
| 1184 def extract_new_config(self, *path, **kwds): | |
| 1185 """Get the value at `path` and make a new :class:`~.Configuration` from it. | |
| 1186 | |
| 1187 The new config is a deepcopy and completely independent of the source | |
| 1188 configuration. | |
| 1189 | |
| 1190 """ | |
| 1191 return self.__class__(copy.deepcopy(self.getvarl(*path, **kwds))) | |
| 1192 | |
| 1183 | 1193 |
| 1184 class _JailedConfiguration(CoercingMethodsMixin): | 1194 class _JailedConfiguration(CoercingMethodsMixin): |
| 1185 | 1195 |
| 1186 """A jailed and restricted variant of :class:`Configuration`. | 1196 """A jailed and restricted variant of :class:`Configuration`. |
| 1187 | 1197 |
