diff options
author | fuzzyman <devnull@localhost> | 2010-01-09 00:18:10 +0000 |
---|---|---|
committer | fuzzyman <devnull@localhost> | 2010-01-09 00:18:10 +0000 |
commit | 2a52ebd76e3ab8db7431d6f61f2d956775905e1e (patch) | |
tree | e918e48b44b496787d20fa08c377f1fff6bd1b80 /docs | |
parent | 75fa0d79daa46aa6c71684b9af0bbcc198f38ecb (diff) | |
download | configobj-git-2a52ebd76e3ab8db7431d6f61f2d956775905e1e.tar.gz |
Minor change to get_extra_values function
Diffstat (limited to 'docs')
-rw-r--r-- | docs/configobj.txt | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/docs/configobj.txt b/docs/configobj.txt index 30ddb6c..f5d04ec 100644 --- a/docs/configobj.txt +++ b/docs/configobj.txt @@ -2161,12 +2161,58 @@ Here is an example of how you could present this information to the user. print section_string, ' = ', error -extra_values -============ +get_extra_values +================ + + +.. code-block:: python + + get_extra_values(conf) + +New in ConfigObj 4.7.0. + +Find all the values and sections not in the configspec from a validated +ConfigObj. + +``get_extra_values`` returns a list of tuples where each tuple represents +either an extra section, or an extra value. + +The tuples contain two values, a tuple representing the section the value +is in and the name of the extra values. For extra values in the top level +section the first member will be an empty tuple. For values in the 'foo' +section the first member will be ``('foo',)``. For members in the 'bar' +subsection of the 'foo' section the first member will be ``('foo', 'bar')``. + +NOTE: If you call ``get_extra_values`` on a ConfigObj instance that hasn't +been validated it will return an empty list. + + +Example Usage +------------- + +The output from ``get_extra_values`` is a list of tuples. -:: +Here is an example of how you could present this information to the user. +.. code-block:: python + + vtor = validate.Validator() + # ini is your config file - cs is the configspec + cfg = ConfigObj(ini, configspec=cs) + cfg.validate(vtor, preserve_errors=True) + + for sections, name in get_extra_values(cfg): + # this code gets the extra values themselves + the_section = cfg + for section in sections: + the_section = cfg[section] + # the_value may be a section or a value + the_value = the_section[name] + + + + CREDITS ======= |