Mercurial > hgrepos > Python > libs > ConfigMix
changeset 375:baedd2031074
Docs: Introduce the newly introduces access methods
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 11 Jul 2021 17:28:31 +0200 |
| parents | 4d7ad20cb8f9 |
| children | c2e427d49209 |
| files | docs/introduction.rst |
| diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/introduction.rst Sun Jul 11 17:28:01 2021 +0200 +++ b/docs/introduction.rst Sun Jul 11 17:28:31 2021 +0200 @@ -223,7 +223,7 @@ Because the configuration is not only a plain list of but a tree of key-value pairs you will want to fetch a nested configuration value -using two access methods: +using two access basic methods: :py:meth:`.Configuration.getvar` and :py:meth:`.Configuration.getvar_s` @@ -234,6 +234,18 @@ Use just positional Python arguments for each level key +Also there exist variants of the basic access methods that coerce +returned variables into :py:class:`int` or :py:class:`bool` types +(:py:meth:`.Configuration.getintvar_s`, +:py:meth:`.Configuration.getboolvar_s`) + +And with :py:meth:`.Configuration.getfirstvar`, +:py:meth:`.Configuration.getfirstvar_s`, +:py:meth:`.Configuration.getfirstintvar_s` and +:py:meth:`.Configuration.getfirstboolvar_s` there exist variants that +accept a *list* of possible variables names and return the first one +that is found. + Looking at the example in chapter :ref:`yaml-files` -- when calling ``config.getvar_s("tree1.tree2.key4")`` you will get the value ``get this as `tree1.tree2.key4'``.
