# HG changeset patch # User Franz Glasner # Date 1640000597 -3600 # Node ID be6ef72c55d5256be7d360f235e54ee965202896 # Parent 09b8e28b7a44850b790d5adef5b179614bbddf4d Change Configuration.expand_variable() to Configuration.interpolate_variables() diff -r 09b8e28b7a44 -r be6ef72c55d5 CHANGES.txt --- a/CHANGES.txt Mon Dec 20 02:00:03 2021 +0100 +++ b/CHANGES.txt Mon Dec 20 12:43:17 2021 +0100 @@ -22,6 +22,10 @@ * :py:meth:`~configmix.config.Configuration.expand_if_reference` * :py:meth:`~configmix.config.Configuration._lookupref` +- **[breaking]** + Change methodname from `expand_variable()` to + :py:meth:`configmix.config.Configuration.interpolate_variables` + - **[misc]** Improved overall performance by a factor of 0.25 to 0.3 diff -r 09b8e28b7a44 -r be6ef72c55d5 configmix/config.py --- a/configmix/config.py Mon Dec 20 02:00:03 2021 +0100 +++ b/configmix/config.py Mon Dec 20 12:43:17 2021 +0100 @@ -753,7 +753,7 @@ ty = type(obj) if issubclass(ty, _TEXTTYPE): # a string - really replace the value - return self.expand_variable(obj) + return self.interpolate_variables(obj) elif issubclass(ty, dict): newdict = ty() for k, v in obj.items(): @@ -770,8 +770,8 @@ else: return obj - def expand_variable(self, s): - """Expand variables in the single string `s`""" + def interpolate_variables(self, s): + """Expand all variables in the single string `s`""" start = s.find(_STARTTOK, 0) if start < 0: return s diff -r 09b8e28b7a44 -r be6ef72c55d5 docs/changes.rst --- a/docs/changes.rst Mon Dec 20 02:00:03 2021 +0100 +++ b/docs/changes.rst Mon Dec 20 12:43:17 2021 +0100 @@ -25,6 +25,9 @@ * Configuration.expand_if_reference() * Configuration._lookupref() +- Change methodname from `expand_variable()` to + :py:meth:`configmix.config.Configuration.interpolate_variables` + 0.19 ---- diff -r 09b8e28b7a44 -r be6ef72c55d5 tests/test.py --- a/tests/test.py Mon Dec 20 02:00:03 2021 +0100 +++ b/tests/test.py Mon Dec 20 12:43:17 2021 +0100 @@ -417,17 +417,17 @@ def test08_None_filter_single(self): cfg = self._load() - x = cfg.expand_variable("{{non-existing|None}}") + x = cfg.interpolate_variables("{{non-existing|None}}") self.assertIsNone(x) def test09_None_filter_embedded(self): cfg = self._load() - x = cfg.expand_variable("A{{non-existing|None}}Z") + x = cfg.interpolate_variables("A{{non-existing|None}}Z") self.assertEqual("AZ", x) def test10_Empty_filtersingle(self): cfg = self._load() - x = cfg.expand_variable("{{non-existing|Empty}}") + x = cfg.interpolate_variables("{{non-existing|Empty}}") self.assertEqual("", x) def test11_None_filter_pass_through(self): @@ -436,7 +436,7 @@ os.path.join(TESTDATADIR, "conf22.ini"), os.path.join(TESTDATADIR, "conf23.json"), os.path.join(TESTDATADIR, "conf24.toml")) - x = cfg.expand_variable("{{intl.cache.items|None}}") + x = cfg.interpolate_variables("{{intl.cache.items|None}}") self.assertEqual(10, x) def test12_Empty_filter_pass_through(self): @@ -445,7 +445,7 @@ os.path.join(TESTDATADIR, "conf22.ini"), os.path.join(TESTDATADIR, "conf23.json"), os.path.join(TESTDATADIR, "conf24.toml")) - x = cfg.expand_variable("{{intl.cache.items|Empty}}") + x = cfg.interpolate_variables("{{intl.cache.items|Empty}}") self.assertEqual(10, x) def test13_keyerror(self):