docstrings and api

This commit is contained in:
gwen
2013-05-23 17:51:50 +02:00
parent 879a415e75
commit c6c422f472
4 changed files with 51 additions and 41 deletions

View File

@ -351,8 +351,34 @@ class SubConfig(BaseInformation):
def make_dict(self, flatten=False, _currpath=None, withoption=None,
withvalue=None):
"""export the whole config into a `dict`
"""exports the whole config into a `dict`, for example:
>>> print cfg.make_dict()
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None}
:param flatten: returns a dict(name=value) instead of a dict(path=value)
::
>>> print cfg.make_dict(flatten=True)
{'var5': None, 'var4': None, 'var6': None}
:param withoption: returns the options that are present in the very same
`OptionDescription` than the `withoption` itself::
>>> print cfg.make_dict(withoption='var1')
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
'od2.var1': u'value', 'od1.var1': None,
'od1.var3': None, 'od1.var2': None}
:param withvalue: returns the options that have the value `withvalue`
::
>>> print c.make_dict(withoption='var1', withvalue=u'value')
{'od2.var4': None, 'od2.var5': None, 'od2.var6': None,
'od2.var1': u'value'}
:returns: dict of Option's name (or path) and values
"""
pathsvalues = []

View File

@ -25,9 +25,9 @@ from tiramisu.i18n import _
class Values(object):
"""`Config`'s root indeed is in charge of the `Option()`'s values,
and the values are physicaly located here. `Values` is also
responsible for a caching utility.
"""The `Config`'s root is indeed in charge of the `Option()`'s values,
but the values are physicaly located here, in `Values`, wich is also
responsible of a caching utility.
"""
__slots__ = ('context', '_values', '_cache')