From d9c8e06236f2e20c6a02b0eef57f1f3943422c1d Mon Sep 17 00:00:00 2001 From: gwen Date: Wed, 28 Nov 2012 10:14:16 +0100 Subject: [PATCH] config's string representation --- tiramisu/config.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index 0b50a6c..1170e64 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -409,27 +409,21 @@ class Config(object): except: pass # hidden, disabled option # ______________________________________________________________________ - def __str__(self, indent=""): + def __str__(self): "Config's string representation" lines = [] - children = [(child._name, child) - for child in self._cfgimpl_descr._children] - children.sort() - for name, child in children: - if self._cfgimpl_value_owners.get(name, None) == 'default': - continue - value = getattr(self, name) - if isinstance(value, Config): - substr = value.__str__(indent + " ") - else: - substr = "%s %s = %s" % (indent, name, value) - if substr: - lines.append(substr) - if indent and not lines: - return '' # hide subgroups with all default values - lines.insert(0, "%s[%s]" % (indent, self._cfgimpl_descr._name,)) + for name, grp in self.iter_groups(): + lines.append("[%s]" % name) + for name, value in self: + try: + lines.append("%s = %s" % (name, value)) + except: + pass return '\n'.join(lines) + __repr__ = __str__ + + def getpaths(self, include_groups=False, allpaths=False, mandatory=False): """returns a list of all paths in self, recursively, taking care of the context of properties (hidden/disabled)