report: options work again
This commit is contained in:
parent
0846ca9890
commit
7c640bee4c
2 changed files with 66 additions and 21 deletions
|
@ -26,8 +26,9 @@ def descr_content(path, prefix, descr, root=False):
|
||||||
content.add(ListItem().join(Strong("description:"), Text(descr.impl_get_information('doc'))))
|
content.add(ListItem().join(Strong("description:"), Text(descr.impl_get_information('doc'))))
|
||||||
if not root:
|
if not root:
|
||||||
content.add(ListItem().join(Strong("container:"), Text(prefix)))
|
content.add(ListItem().join(Strong("container:"), Text(prefix)))
|
||||||
if not root:
|
# FIXME
|
||||||
content.add(ListItem().join(Strong("type:"), Text(descr.group_type)))
|
# if not root:
|
||||||
|
# content.add(ListItem().join(Strong("type:"), Text(descr.group_type)))
|
||||||
if not root:
|
if not root:
|
||||||
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
|
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
|
||||||
# FIXME
|
# FIXME
|
||||||
|
@ -60,18 +61,21 @@ def opt_rst_content(path, prefix, descr, value):
|
||||||
content.add(ListItem().join(Strong("value:"), Text(str(value))))
|
content.add(ListItem().join(Strong("value:"), Text(str(value))))
|
||||||
content.add(ListItem().join(Strong("path:"), Text(path)))
|
content.add(ListItem().join(Strong("path:"), Text(path)))
|
||||||
content.add(ListItem().join(Strong("container:"), Text(prefix)))
|
content.add(ListItem().join(Strong("container:"), Text(prefix)))
|
||||||
if isinstance(descr, ChoiceOption):
|
# FIXME
|
||||||
content.add(ListItem().join(Strong("possible values:"), Text(str(descr.values))))
|
# if isinstance(descr, ChoiceOption):
|
||||||
|
# content.add(ListItem().join(Strong("possible values:"), Text(str(descr.values))))
|
||||||
if not isinstance(descr, SymLinkOption):
|
if not isinstance(descr, SymLinkOption):
|
||||||
content.add(ListItem().join(Strong("type:"), Text(str(descr.opt_type))))
|
# FIXME
|
||||||
content.add(ListItem().join(Strong("default:"), Text(str(descr.getdefault()))))
|
# content.add(ListItem().join(Strong("type:"), Text(str(descr.opt_type))))
|
||||||
content.add(ListItem().join(Strong("description:"), Text(str(descr.getdoc()))))
|
# content.add(ListItem().join(Strong("default:"), Text(str(descr.getdefault()))))
|
||||||
|
content.add(ListItem().join(Strong("description:"), Text(str(descr.impl_get_information('doc')))))
|
||||||
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
|
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
|
||||||
content.add(ListItem().join(Strong("is hidden:"), Text(str(descr._is_hidden()))))
|
# FIXME
|
||||||
content.add(ListItem().join(Strong("is disabled:"), Text(str(descr._is_disabled()))))
|
# content.add(ListItem().join(Strong("is hidden:"), Text(str(descr._is_hidden()))))
|
||||||
content.add(ListItem().join(Strong("is frozen:"), Text(str(descr._frozen))))
|
# content.add(ListItem().join(Strong("is disabled:"), Text(str(descr._is_disabled()))))
|
||||||
content.add(ListItem().join(Strong("is multi:"), Text(str(descr.multi))))
|
# content.add(ListItem().join(Strong("is frozen:"), Text(str(descr._frozen))))
|
||||||
content.add(ListItem().join(Strong("is mandatory:"), Text(str(descr.is_mandatory()))))
|
# content.add(ListItem().join(Strong("is multi:"), Text(str(descr.multi))))
|
||||||
|
# content.add(ListItem().join(Strong("is mandatory:"), Text(str(descr.is_mandatory()))))
|
||||||
else:
|
else:
|
||||||
content.add(ListItem().join(Strong("links to:"), Text(str(descr.path))))
|
content.add(ListItem().join(Strong("links to:"), Text(str(descr.path))))
|
||||||
content.add(Transition())
|
content.add(Transition())
|
||||||
|
@ -82,15 +86,16 @@ def make_rest_overview(cfg, title=True):
|
||||||
descr = cfg._impl_descr
|
descr = cfg._impl_descr
|
||||||
rootname = descr._name
|
rootname = descr._name
|
||||||
descr_content(rootname, rootname, descr, root=True)
|
descr_content(rootname, rootname, descr, root=True)
|
||||||
# for path in cfg.getpaths(include_groups=True, allpaths=True):
|
|
||||||
# child = cfg.unwrap_from_path(path)
|
for path in descr.impl_getpaths(include_groups=True):
|
||||||
# fullpath = rootname + '.' + path
|
child = cfg.unwrap_from_path(path)
|
||||||
# prefix = fullpath.rsplit(".", 1)[0]
|
fullpath = rootname + '.' + path
|
||||||
# if isinstance(child, OptionDescription):
|
prefix = fullpath.rsplit(".", 1)[0]
|
||||||
# descr_content(fullpath, prefix, child)
|
if isinstance(child, OptionDescription):
|
||||||
# else:
|
descr_content(fullpath, prefix, child)
|
||||||
# value = getattr(cfg, path)
|
else:
|
||||||
# opt_rst_content(fullpath, prefix, child, value)
|
value = getattr(cfg, path)
|
||||||
|
opt_rst_content(fullpath, prefix, child, value)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from sampleconfig import get_example_config
|
from sampleconfig import get_example_config
|
||||||
|
|
40
report/tool.py
Normal file
40
report/tool.py
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# Copyright (C) 2012 Team tiramisu (see AUTHORS for all contributors)
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# The original `Config` design model is unproudly borrowed from
|
||||||
|
# the rough gus of pypy: pypy: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||||
|
# the whole pypy projet is under MIT licence
|
||||||
|
from tiramisu.config import Config
|
||||||
|
from tiramisu.option import (OptionDescription, Option, ChoiceOption, BoolOption,
|
||||||
|
FloatOption, StrOption, IntOption, IPOption, NetmaskOption,
|
||||||
|
apply_requires)
|
||||||
|
|
||||||
|
# extendable type
|
||||||
|
class extend(type):
|
||||||
|
"""
|
||||||
|
A magic trick for classes, which lets you add methods or attributes to a
|
||||||
|
class
|
||||||
|
"""
|
||||||
|
def extend(cls, extclass):
|
||||||
|
bases = list(extclass.__bases__)
|
||||||
|
bases.append(extclass)
|
||||||
|
for cl in bases:
|
||||||
|
for key, value in cl.__dict__.items():
|
||||||
|
if key == '__module__':
|
||||||
|
continue
|
||||||
|
setattr(cls, key, value)
|
||||||
|
|
||||||
|
# ____________________________________________________________
|
Loading…
Reference in a new issue