Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/config.py @ 383:5c72da46b8ae
Implemented Configuration.getfirstfloatvar_s().
This was missing.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 10 Nov 2021 01:53:23 +0100 |
| parents | 24db29162d09 |
| children | 8c3aaa894089 |
line wrap: on
line diff
--- a/configmix/config.py Wed Nov 10 01:42:15 2021 +0100 +++ b/configmix/config.py Wed Nov 10 01:53:23 2021 +0100 @@ -367,6 +367,17 @@ else: return s + def getfirstfloatvar_s(self, varname, default=_MARKER): + """Get a (possibly substituted) variable and convert text to a + float + + """ + s = self.getfirstvar_s(varname, default) + if isinstance(s, self._TEXTTYPE): + return float(s) + else: + return s + def _split_ns(self, s): nameparts = s.split(self._NS_SEPARATOR, 1) if len(nameparts) == 1:
