Fix nested dumping output (using prefix and nested config names).
authorW. Trevor King <wking@drexel.edu>
Thu, 8 Sep 2011 14:39:21 +0000 (10:39 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 8 Sep 2011 14:39:21 +0000 (10:39 -0400)
h5config/config.py

index ce195e60f8a9887cc2612c907fb71c16f1e5e086..65687603917fdb31cd19394d6fa855d746b2a1a5 100644 (file)
@@ -302,12 +302,15 @@ class Config (dict):
             try:
                 if isinstance(setting, ConfigListSetting):
                     if value:
-                        for config in value:
+                        lines.append('{}{}:'.format(prefix, name))
+                        for i,config in enumerate(value):
+                            lines.append('{}  {}:'.format(prefix, i))
                             lines.append(
-                                config.dump(help=help, prefix=prefix+'  '))
+                                config.dump(help=help, prefix=prefix+'    '))
                         continue
                 elif isinstance(setting, ConfigSetting):
                     if value is not None:
+                        lines.append('{}{}:'.format(prefix, name))
                         lines.append(value.dump(help=help, prefix=prefix+'  '))
                         continue
                 value_string = setting.convert_to_text(self[name])
@@ -315,8 +318,8 @@ class Config (dict):
                     help_string = '\t({})'.format(setting.help())
                 else:
                     help_string = ''
-                lines.append('{}: {}{}'.format(
-                        name, value_string, help_string))
+                lines.append('{}{}: {}{}'.format(
+                        prefix, name, value_string, help_string))
             except Exception:
                 _LOG.error('could not dump {} ({!r})'.format(name, value))
                 raise