tiramisu/doc/configapi.txt

105 lines
3 KiB
Text
Raw Normal View History

.. default-role:: literal
2012-11-20 17:14:58 +01:00
.. module:: tiramisu.config
2012-11-20 17:14:58 +01:00
`tiramisu.config`, the configuration management main entry
================================================================
2012-10-05 16:00:07 +02:00
The handling of options is split into two parts: the description of
which options are available, what their possible values and defaults are
and how they are organized into a tree. A specific choice of options is
bundled into a configuration object which has a reference to its option
description (and therefore makes sure that the configuration values
adhere to the option description).
2012-11-20 17:14:58 +01:00
The configuration object important methods
---------------------------------------------
2012-11-20 17:14:58 +01:00
`config.Config()` object that lives in `config.py` hold the
2012-10-05 16:00:07 +02:00
choosen values for the options (or the default value for the
2012-11-20 17:14:58 +01:00
`option.Option()` object, if no choice was made).
2012-11-20 17:14:58 +01:00
A `Config` object is informed by an `option.OptionDescription`
2012-10-05 16:00:07 +02:00
instance. The attributes of the ``Config`` objects are the names of the
children of the ``OptionDescription``.
Here are the (useful) methods on ``Config``:
2012-11-20 17:14:58 +01:00
.. currentmodule:: tiramisu.config
2012-11-20 17:14:58 +01:00
.. autoclass:: Config
2012-11-20 17:14:58 +01:00
.. automethod:: __init__
.. rubric:: Methods
.. autosummary::
~Config.__init__
~Config.set
~Config.setoption
.. automethod:: set
.. automethod:: setoption
2012-10-05 16:00:07 +02:00
Here are some private attributes of a `Config()` object, for a
comprehension of the internal merchanism:
2012-10-05 16:00:07 +02:00
2012-11-20 17:14:58 +01:00
- `_cfgimpl_descr =` `option.OptionDescription()`,
2013-02-19 11:24:17 +01:00
e.g. the :ref:`optdescr`
2012-11-20 17:14:58 +01:00
- `_cfgimpl_values` contains the `option.Option()`'s values.
Yes, the values of the options: remember that the values are stored **inside**
2012-11-20 17:14:58 +01:00
the `config.Config()` and not in the `Option()`
2012-10-05 16:00:07 +02:00
`_cfgimpl_values` contains something like that
::
{'int': 0, 'wantframework': False, 'objspace': 'std', 'bool': False,
2013-02-19 11:24:17 +01:00
'str': 'abc', 'wantref': False}
2012-10-05 16:00:07 +02:00
We can see that values can also be config objects, it's the
sub-namespaces that are stored in the values as `Config()` objects.
convenience utilities (iteration, exports...)
-----------------------------------------------
2012-11-20 17:14:58 +01:00
With this `config.Config()` configuration management entry point,
it is possible to
2012-10-05 16:00:07 +02:00
- `iter` on config, notice that there is an iteration order wich is
2013-02-19 11:24:17 +01:00
the order of the :ref:`optdescr` specification entries,
- compare two configs (equality),
2012-11-20 17:14:58 +01:00
- export the whole config into a `dict` with `config.make_dict()`,
2012-11-20 17:14:58 +01:00
`option.Option()` objects in a config are iterable in the pythonic
2012-10-05 16:00:07 +02:00
way, that is something like `[(name, value) for name, value in config]`.
To iter on groups in the same manner, use the
2012-11-20 17:14:58 +01:00
`config.Config.iter_groups()` method wich yields generators too.
**iteration utilities**
2012-11-20 17:14:58 +01:00
.. autoclass:: Config
.. automethod:: __init__
.. rubric:: Methods
.. autosummary::
~Config.get
~Config.find
~Config.find_first
~Config.getpaths
~Config.iter_groups
~Config.__iter__
2012-10-05 16:00:07 +02:00
2012-11-20 17:14:58 +01:00
.. automethod:: get
.. automethod:: find
.. automethod:: find_first
.. automethod:: getpaths
.. automethod:: iter_groups
.. automethod:: __iter__