doc is ready for the new api refactoring
This commit is contained in:
parent
d6098f353e
commit
9acb522791
|
@ -4,8 +4,11 @@
|
||||||
Configuration handling basics
|
Configuration handling basics
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
`Config` and `Option` objects
|
Tiramisu is designed with three main objects :
|
||||||
================================
|
|
||||||
|
- :class:`tiramisu.config.Config` witch is the whole configuration entry point
|
||||||
|
- :class:`tiramisu.option.Option` stands for the option type
|
||||||
|
- :class:`tiramisu.option.OptionDescription` stands for the description (the schema)
|
||||||
|
|
||||||
Accessing the configuration `Option`'s
|
Accessing the configuration `Option`'s
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
@ -62,20 +65,6 @@ What if a value has been set and `None` is to be returned again ? Don't
|
||||||
worry, an option value can be "reseted" with the help of the `option.Option.reset()`
|
worry, an option value can be "reseted" with the help of the `option.Option.reset()`
|
||||||
method.
|
method.
|
||||||
|
|
||||||
If you do not want to use the pythonic way, that is the attribute access
|
|
||||||
way to obtain the value of the configuration option, you can also search
|
|
||||||
for it recursively in the whole config namespaces with the ``get()``
|
|
||||||
method :
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
>>> config.get('bool')
|
|
||||||
True
|
|
||||||
|
|
||||||
To find the right option, `get()` searches recursively into the whole
|
|
||||||
tree. For example, to find an option which is in the `gc` namespace
|
|
||||||
there are two possibilites.
|
|
||||||
|
|
||||||
If you know the path:
|
If you know the path:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
@ -83,13 +72,6 @@ If you know the path:
|
||||||
>>> config.gc.dummy
|
>>> config.gc.dummy
|
||||||
False
|
False
|
||||||
|
|
||||||
If you don't remember the path:
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
>>> config.get('dummy')
|
|
||||||
False
|
|
||||||
|
|
||||||
Setting the values of the options
|
Setting the values of the options
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
|
@ -101,13 +83,6 @@ the first one is of course the `__setattr__` method
|
||||||
|
|
||||||
cfg.name = value
|
cfg.name = value
|
||||||
|
|
||||||
wich has the same effect that the "global" `set()` method (it expects that
|
|
||||||
the value owner is the default)
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
cfg.set(name=value)
|
|
||||||
|
|
||||||
.. module:: tiramisu.config
|
.. module:: tiramisu.config
|
||||||
|
|
||||||
The handling of options is split into two parts: the description of
|
The handling of options is split into two parts: the description of
|
||||||
|
@ -117,12 +92,8 @@ bundled into a configuration object which has a reference to its option
|
||||||
description (and therefore makes sure that the configuration values
|
description (and therefore makes sure that the configuration values
|
||||||
adhere to the option description).
|
adhere to the option description).
|
||||||
|
|
||||||
The configuration object important methods
|
Configuration's interesting methods
|
||||||
---------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
`config.Config()` object that lives in `config.py` hold the
|
|
||||||
choosen values for the options (or the default value for the
|
|
||||||
`option.Option()` object, if no choice was made).
|
|
||||||
|
|
||||||
A `Config` object is informed by an `option.OptionDescription`
|
A `Config` object is informed by an `option.OptionDescription`
|
||||||
instance. The attributes of the ``Config`` objects are the names of the
|
instance. The attributes of the ``Config`` objects are the names of the
|
||||||
|
@ -130,26 +101,6 @@ children of the ``OptionDescription``.
|
||||||
|
|
||||||
Here are the (useful) methods on ``Config``:
|
Here are the (useful) methods on ``Config``:
|
||||||
|
|
||||||
.. currentmodule:: tiramisu.config
|
|
||||||
|
|
||||||
.. autoclass:: Config
|
|
||||||
|
|
||||||
.. automethod:: __init__
|
|
||||||
|
|
||||||
.. rubric:: Methods
|
|
||||||
|
|
||||||
.. autosummary::
|
|
||||||
|
|
||||||
~Config.__init__
|
|
||||||
~Config.set
|
|
||||||
|
|
||||||
.. automethod:: set
|
|
||||||
|
|
||||||
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...)
|
|
||||||
-----------------------------------------------
|
|
||||||
|
|
||||||
With this `config.Config()` configuration management entry point,
|
With this `config.Config()` configuration management entry point,
|
||||||
it is possible to
|
it is possible to
|
||||||
|
@ -165,7 +116,7 @@ way, that is something like `[(name, value) for name, value in config]`.
|
||||||
To iter on groups in the same manner, use the
|
To iter on groups in the same manner, use the
|
||||||
`config.Config.iter_groups()` method wich yields generators too.
|
`config.Config.iter_groups()` method wich yields generators too.
|
||||||
|
|
||||||
**iteration utilities**
|
.. currentmodule:: tiramisu.config
|
||||||
|
|
||||||
.. autoclass:: Config
|
.. autoclass:: Config
|
||||||
|
|
||||||
|
@ -175,16 +126,12 @@ To iter on groups in the same manner, use the
|
||||||
|
|
||||||
.. autosummary::
|
.. autosummary::
|
||||||
|
|
||||||
~Config.get
|
|
||||||
~Config.find
|
~Config.find
|
||||||
~Config.find_first
|
~Config.find_first
|
||||||
~Config.getpaths
|
|
||||||
~Config.iter_groups
|
~Config.iter_groups
|
||||||
~Config.__iter__
|
~Config.__iter__
|
||||||
|
|
||||||
.. automethod:: get
|
|
||||||
.. automethod:: find
|
.. automethod:: find
|
||||||
.. automethod:: find_first
|
.. automethod:: find_first
|
||||||
.. automethod:: getpaths
|
|
||||||
.. automethod:: iter_groups
|
.. automethod:: iter_groups
|
||||||
.. automethod:: __iter__
|
.. automethod:: __iter__
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.. default-role:: literal
|
.. default-role:: literal
|
||||||
|
|
||||||
The global configuration's consistency
|
The global consistency
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
Identical option names
|
Identical option names
|
||||||
|
|
|
@ -71,5 +71,5 @@ So by now, we have
|
||||||
:class:`tiramisu.option.BoolOption()`.
|
:class:`tiramisu.option.BoolOption()`.
|
||||||
|
|
||||||
Configuration option objects :class:`tiramisu.config.Config()` are produced at
|
Configuration option objects :class:`tiramisu.config.Config()` are produced at
|
||||||
the entry points and handed down to where they are actually used. This keeps
|
the entry point and then handed down to where they are actually used. This
|
||||||
configuration local but available everywhere and consistent.
|
keeps configuration local but available everywhere and consistent.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.. default-role:: literal
|
.. default-role:: literal
|
||||||
|
|
||||||
glossary
|
Glossary
|
||||||
==========
|
==========
|
||||||
|
|
||||||
.. glossary::
|
.. glossary::
|
||||||
|
@ -43,8 +43,8 @@ glossary
|
||||||
|
|
||||||
acces rules
|
acces rules
|
||||||
|
|
||||||
Access rules are : `config.Config.cfgimpl_read_write()` or
|
Access rules are : `config.Config.read_write()` or
|
||||||
`config.Config.cfgimpl_read_only()`, see :doc:`status`
|
`config.Config.read_only()`, see :doc:`status`
|
||||||
|
|
||||||
.. glossary::
|
.. glossary::
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.. default-role:: literal
|
.. default-role:: literal
|
||||||
|
|
||||||
The `tiramisu.option.Option` options
|
The options
|
||||||
======================================
|
===============
|
||||||
|
|
||||||
Description of Options
|
Description of Options
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -20,33 +20,23 @@ The `OptionDescription` class
|
||||||
|
|
||||||
.. module:: tiramisu.option
|
.. module:: tiramisu.option
|
||||||
|
|
||||||
.. autoclass: OptionDescription
|
.. autoclass:: OptionDescription
|
||||||
|
:special-members:
|
||||||
|
:members:
|
||||||
|
|
||||||
.. automethod:: __init__
|
|
||||||
|
|
||||||
.. rubric:: Methods
|
|
||||||
|
|
||||||
.. autosummary::
|
|
||||||
|
|
||||||
~Config.__init__
|
|
||||||
~Config.set_group_type
|
|
||||||
|
|
||||||
.. automethod:: set_group_type
|
|
||||||
|
|
||||||
`Options description` objects lives in the :class:`tiramisu.config.Config` attribute.
|
|
||||||
|
|
||||||
If you need to access an option object, you can do it with the OptionDescription
|
If you need to access an option object, you can do it with the OptionDescription
|
||||||
object. Not only the value of the option by attribute access, but the option
|
object. Not only the value of the option by attribute access, but the option
|
||||||
object itself that lives behind the scene. It can always be accessed internally
|
object itself that lives behind the scene. It can always be accessed internally
|
||||||
with the `_cfgimpl_descr` attribute of the `config` objects. For example, with a
|
with the `impl_descr` attribute of the `config` objects. For example, with a
|
||||||
option named `name` in a `gc` group the `name` object can be accessed like
|
option named `name` in a `gc` group the `name` object can be accessed like
|
||||||
this::
|
this::
|
||||||
|
|
||||||
conf._cfgimpl_descr.name
|
conf._impl_descr.name
|
||||||
|
|
||||||
of sub configs with ::
|
of sub configs with ::
|
||||||
|
|
||||||
conf.gc._cfgimpl_descr.name
|
conf.gc._impl_descr.name
|
||||||
|
|
||||||
This is a binding. The option objects are in the `_children` config's attribute.
|
This is a binding. The option objects are in the `_children` config's attribute.
|
||||||
|
|
||||||
|
@ -55,7 +45,7 @@ configuration option
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
conf.gc._cfgimpl_descr.dummy.freeze()
|
conf.gc._impl_descr.dummy.freeze()
|
||||||
|
|
||||||
or to hide it, or disable it, or... anything.
|
or to hide it, or disable it, or... anything.
|
||||||
|
|
||||||
|
@ -110,6 +100,3 @@ configuration, that is :
|
||||||
.. autoclass:: ChoiceOption
|
.. autoclass:: ChoiceOption
|
||||||
|
|
||||||
.. automethod:: __init__
|
.. automethod:: __init__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
.. TODO: STATUS and settings explained
|
.. TODO: STATUS and settings explained
|
||||||
|
|
||||||
Configuration status
|
The statuses
|
||||||
======================
|
======================
|
||||||
|
|
||||||
Available configuration statuses
|
Available configuration statuses
|
||||||
|
@ -21,7 +21,7 @@ method:
|
||||||
possible to modify a disabled option.
|
possible to modify a disabled option.
|
||||||
|
|
||||||
To enable read-write status, call
|
To enable read-write status, call
|
||||||
`setting.Setting.read_write()`
|
`congi.Config.read_write()`
|
||||||
|
|
||||||
**read only status**
|
**read only status**
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ method:
|
||||||
The configuration has not an access to the hidden options
|
The configuration has not an access to the hidden options
|
||||||
but can read the disabled options.
|
but can read the disabled options.
|
||||||
|
|
||||||
To enable read only status, call `setting.Setting.read_only()`
|
To enable read only status, call `config.Config.read_only()`
|
||||||
|
|
||||||
.. csv-table:: **Configuration's statuses summary**
|
.. csv-table:: **Configuration's statuses summary**
|
||||||
:header: " ", "Hidden", "Disabled", "Mandatory"
|
:header: " ", "Hidden", "Disabled", "Mandatory"
|
||||||
|
|
|
@ -108,6 +108,7 @@ class Option(BaseInformation):
|
||||||
:param validator: the name of a function wich stands for a custom
|
:param validator: the name of a function wich stands for a custom
|
||||||
validation of the value
|
validation of the value
|
||||||
:param validator_args: the validator's parameters
|
:param validator_args: the validator's parameters
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not valid_name(name):
|
if not valid_name(name):
|
||||||
raise ValueError(_("invalid name: {0} for option").format(name))
|
raise ValueError(_("invalid name: {0} for option").format(name))
|
||||||
|
@ -606,14 +607,16 @@ class DomainnameOption(Option):
|
||||||
|
|
||||||
|
|
||||||
class OptionDescription(BaseInformation):
|
class OptionDescription(BaseInformation):
|
||||||
"""Config's schema (organisation, group) and container of Options"""
|
"""Config's schema (organisation, group) and container of Options
|
||||||
|
The `OptionsDescription` objects lives in the `tiramisu.config.Config`.
|
||||||
|
"""
|
||||||
__slots__ = ('_name', '_requires', '_cache_paths', '_group_type',
|
__slots__ = ('_name', '_requires', '_cache_paths', '_group_type',
|
||||||
'_properties', '_children', '_consistencies')
|
'_properties', '_children', '_consistencies')
|
||||||
|
|
||||||
def __init__(self, name, doc, children, requires=None, properties=None):
|
def __init__(self, name, doc, children, requires=None, properties=None):
|
||||||
"""
|
"""
|
||||||
:param children: is a list of option descriptions (including
|
:param children: a list of options (including option descriptions)
|
||||||
``OptionDescription`` instances for nested namespaces).
|
|
||||||
"""
|
"""
|
||||||
if not valid_name(name):
|
if not valid_name(name):
|
||||||
raise ValueError(_("invalid name: {0} for option descr").format(name))
|
raise ValueError(_("invalid name: {0} for option descr").format(name))
|
||||||
|
|
Loading…
Reference in New Issue