import copy as _copy
+from . import LOG as _LOG
+
class Setting (object):
"A named setting with arbitrart text values."
for setting in self.settings:
name = setting.name
value = self[name]
- if isinstance(setting, ConfigSetting):
- if value is not None:
- lines.append(value.dump(help=help, prefix=prefix+' '))
- continue
- elif isinstance(setting, ConfigListSetting):
- if value:
- for config in value:
- lines.append(
- config.dump(help=help, prefix=prefix+' '))
- continue
- value_string = setting.convert_to_text(self[name])
- if help:
- help_string = '\t({})'.format(setting.help())
- else:
- help_string = ''
- lines.append('{}: {}{}'.format(name, value_string, help_string))
+ try:
+ if isinstance(setting, ConfigSetting):
+ if value is not None:
+ lines.append(value.dump(help=help, prefix=prefix+' '))
+ continue
+ elif isinstance(setting, ConfigListSetting):
+ if value:
+ for config in value:
+ lines.append(
+ config.dump(help=help, prefix=prefix+' '))
+ continue
+ value_string = setting.convert_to_text(self[name])
+ if help:
+ help_string = '\t({})'.format(setting.help())
+ else:
+ help_string = ''
+ lines.append('{}: {}{}'.format(
+ name, value_string, help_string))
+ except Exception:
+ _LOG.error('could not dump {} ({!r})'.format(name, value))
+ raise
return '\n'.join(lines)