changeset 525:be6ef72c55d5

Change Configuration.expand_variable() to Configuration.interpolate_variables()
author Franz Glasner <f.glasner@feldmann-mg.com>
date Mon, 20 Dec 2021 12:43:17 +0100
parents 09b8e28b7a44
children 48990863b905
files CHANGES.txt configmix/config.py docs/changes.rst tests/test.py
diffstat 4 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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
--- 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
 ----
--- 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):