config's string representation
authorgwen <gremond@cadoles.com>
Wed, 28 Nov 2012 09:14:16 +0000 (10:14 +0100)
committergwen <gremond@cadoles.com>
Wed, 28 Nov 2012 09:14:16 +0000 (10:14 +0100)
tiramisu/config.py

index 0b50a6c..1170e64 100644 (file)
@@ -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)