changeset 524:09b8e28b7a44

Implement Configuration.getvar_s() by using Configuration.getvarl() instead of Configuration.getvar(). This allows for proper caching of variable interpolation in the future.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 20 Dec 2021 02:00:03 +0100
parents 085962f6c81f
children be6ef72c55d5
files configmix/config.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configmix/config.py	Sun Dec 19 19:01:43 2021 +0100
+++ b/configmix/config.py	Mon Dec 20 02:00:03 2021 +0100
@@ -611,8 +611,17 @@
         For more details see chapter :ref:`variable-interpolation`.
 
         """
+        varns, varname = self._split_ns(varname)
+        if not varns:
+            if varname:
+                varnameparts = tuple([unquote(vp)
+                                      for vp in varname.split(_HIER_SEPARATOR)])
+            else:
+                varnameparts = tuple()
+        else:
+            varnameparts = (varname,)
         try:
-            obj = self.getvar(varname)
+            obj = self.getvarl(*varnameparts, namespace=varns)
             return self.substitute_variables_in_obj(obj)
         except KeyError:
             if default is _MARKER: