Esempio n. 1
0
def rest_format_section(stream, section, options, doc=None):
    """format an options section using the INI format"""
    if section:
        print >> stream, '%s\n%s' % (section, "'"*len(section))
    if doc:
        print >> stream, normalize_text(doc, line_len=79, indent='')
        print >> stream
    for optname, optdict, value in options:
        help = optdict.get('help')
        print >> stream, ':%s:' % optname
        if help:
            print >> stream, normalize_text(help, line_len=79, indent='  ')
        if value:
            print >> stream, '  Default: %s' % format_option_value(optdict, value)
Esempio n. 2
0
def ini_format_section(stream, section, options, doc=None):
    """format an options section using the INI format"""
    if doc:
        print >> stream, comment(doc)
    print >> stream, '[%s]' % section
    for optname, optdict, value in options:
        value = format_option_value(optdict, value)
        help = optdict.get('help')
        if help:
            print >> stream
            print >> stream, normalize_text(help, line_len=79, indent='# ')
        else:
            print >> stream
        if value is None:
            print >> stream, '#%s=' % optname
        else:
            print >> stream, '%s=%s' % (optname, str(value).strip())