Mercurial > hgrepos > Python > libs > ConfigMix
comparison docs/introduction.rst @ 387:b2c0550d5a44
Docs: minimal introduction for getfirstXXXl_s variants
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 10 Nov 2021 02:38:38 +0100 |
| parents | d7dcd76c262a |
| children | 44ef854da70a |
comparison
equal
deleted
inserted
replaced
| 386:d7dcd76c262a | 387:b2c0550d5a44 |
|---|---|
| 244 :py:meth:`.Configuration.getfirstintvar_s`, | 244 :py:meth:`.Configuration.getfirstintvar_s`, |
| 245 :py:meth:`.Configuration.getfirstboolvar_s` and | 245 :py:meth:`.Configuration.getfirstboolvar_s` and |
| 246 :py:meth:`.Configuration.getfirstfloatvar_s` there exist variants that | 246 :py:meth:`.Configuration.getfirstfloatvar_s` there exist variants that |
| 247 accept a *list* of possible variables names and return the first one | 247 accept a *list* of possible variables names and return the first one |
| 248 that is found. | 248 that is found. |
| 249 | |
| 250 And again --- with :py:meth:`.Configuration.getfirstvarl`, | |
| 251 :py:meth:`.Configuration.getfirstvarl_s`, | |
| 252 :py:meth:`.Configuration.getfirstintvarl_s`, | |
| 253 :py:meth:`.Configuration.getfirstboolvarl_s` and | |
| 254 :py:meth:`.Configuration.getfirstfloatvarl_s` there exist variants | |
| 255 that accept a *list* of lists or tuples or dicts that describe | |
| 256 possible variables names and return the first one that is found. | |
| 257 | |
| 258 For example -- these methods for retrieving the first found variables | |
| 259 can be used and are equivalent:: | |
| 260 | |
| 261 value1 = config.getfirstvar_s("key1.subkey2", "key3.subkey4", default=None, namespace=None) | |
| 262 value2 = config.getfirstvarl_s(*[["key1", "subkey2"], ["key3", "subkey4"]], default=None) | |
| 263 value3 = config.getfirstvarl_s(*(("key1", "subkey2"), ("key3", "subkey4")), default=None) | |
| 264 value4 = config.getfirstvarl_s(*[{"namespace": None, "path": ["key1", "subkey2"]}, {"namespace": None, "path": ("key3", "subkey4")}], default=None) | |
| 249 | 265 |
| 250 Looking at the example in chapter :ref:`yaml-files` -- when calling | 266 Looking at the example in chapter :ref:`yaml-files` -- when calling |
| 251 ``config.getvar_s("tree1.tree2.key4")`` you will get the value | 267 ``config.getvar_s("tree1.tree2.key4")`` you will get the value |
| 252 ``get this as `tree1.tree2.key4'``. | 268 ``get this as `tree1.tree2.key4'``. |
| 253 | 269 |
