comparison configmix/config.py @ 115:a5339d39af5c

Begin the documentation of variables and its expansion
author Franz Glasner <hg@dom66.de>
date Sun, 25 Mar 2018 16:45:15 +0200
parents d9f9a06e0c49
children e2e8d21b4122
comparison
equal deleted inserted replaced
114:aa0c61e79660 115:a5339d39af5c
53 substituted. 53 substituted.
54 54
55 """ 55 """
56 56
57 def getvar(self, varname, default=_MARKER): 57 def getvar(self, varname, default=_MARKER):
58 """Get a variable of the form ``[[ns1.]ns2.]name`` - including 58 """Get a variable of the form ``[ns:][[key1.]key2.]name`` - including
59 variables from other namespaces. 59 variables from other namespaces.
60 60
61 No variable expansion is done and no filters are applied. 61 No variable expansion is done and no filters are applied.
62
62 """ 63 """
63 varns, varname = self._split_ns(varname) 64 varns, varname = self._split_ns(varname)
64 try: 65 try:
65 if not varns: 66 if not varns:
66 lookupfn = self._lookupvar 67 lookupfn = self._lookupvar
76 return varvalue 77 return varvalue
77 78
78 def getvar_s(self, varname, default=_MARKER): 79 def getvar_s(self, varname, default=_MARKER):
79 """Get a variable - including variables from other namespaces. 80 """Get a variable - including variables from other namespaces.
80 81
81 Variables will be substituted recursively in the result. 82 `varname` is interpreted as in :meth:`.getvar`. But variables
83 will be expanded recursively within the variable values and
84 filters are applied.
85
86 For more details see chapter :ref:`variable-expansion`.
87
82 """ 88 """
83 try: 89 try:
84 obj = self.getvar(varname) 90 obj = self.getvar(varname)
85 return self.substitute_variables_in_obj(obj) 91 return self.substitute_variables_in_obj(obj)
86 except KeyError: 92 except KeyError: