Exemplo n.º 1
0
def format_settings_list(settings):
    errors = settings.get_errors()
    lines = []
    for (key, value) in sorted(settings.current.iteritems()):
        default_value = settings.default.get(key)
        masked_value = mask_value_if_secret(key, value)
        lines.append(u'%s: %s' % (key, indent(pformat(masked_value), places=2)))
        if value != default_value and default_value is not None:
            lines.append(u'  Default: %s' %
                indent(pformat(default_value), places=4))
        if errors.get(key) is not None:
            lines.append(u'  Error: %s' % errors[key])
    return '\n'.join(lines)
Exemplo n.º 2
0
def format_settings_list(settings):
    errors = settings.get_errors()
    lines = []
    for (key, value) in sorted(settings.current.iteritems()):
        default_value = settings.default.get(key)
        masked_value = mask_value_if_secret(key, value)
        lines.append(u'%s: %s' %
                     (key, log.indent(pprint.pformat(masked_value), places=2)))
        if value != default_value and default_value is not None:
            lines.append(u'  Default: %s' %
                         log.indent(pprint.pformat(default_value), places=4))
        if errors.get(key) is not None:
            lines.append(u'  Error: %s' % errors[key])
    return '\n'.join(lines)
Exemplo n.º 3
0
def list_settings_optparse_callback(*args):
    """
    Prints a list of all settings.

    Called by optparse when Mopidy is run with the :option:`--list-settings`
    option.
    """
    from mopidy import settings
    errors = settings.get_errors()
    lines = []
    for (key, value) in sorted(settings.current.iteritems()):
        default_value = settings.default.get(key)
        if key.endswith('PASSWORD') and len(value):
            value = u'********'
        lines.append(u'%s:' % key)
        lines.append(u'  Value: %s' % repr(value))
        if value != default_value and default_value is not None:
            lines.append(u'  Default: %s' % repr(default_value))
        if errors.get(key) is not None:
            lines.append(u'  Error: %s' % errors[key])
    print u'Settings: %s' % indent('\n'.join(lines), places=2)
    sys.exit(0)