def ini_format(stream, options, encoding): """format options using the INI format""" for optname, optdict, value in options: value = format_option_value(optdict, value) help = optdict.get('help') if help: help = normalize_text(help, line_len=79, indent='# ') print >> stream print >> stream, _encode(help, encoding) else: print >> stream if value is None: print >> stream, '#%s=' % optname else: value = _encode(value, encoding).strip() print >> stream, '%s=%s' % (optname, value)
def ini_format_section(stream, section, options, encoding=None, doc=None): """format an options section using the INI format""" encoding = _get_encoding(encoding, stream) if doc: print(_encode(comment(doc), encoding), file=stream) print('[%s]' % section, file=stream) ini_format(stream, options, encoding)
def ini_format_section(stream, section, options, encoding=None, doc=None): """format an options section using the INI format""" encoding = _get_encoding(encoding, stream) if doc: print >> stream, _encode(comment(doc), encoding) print >> stream, '[%s]' % section ini_format(stream, options, encoding)
def ini_format(stream, options, encoding): """format options using the INI format""" for optname, optdict, value in options: value = format_option_value(optdict, value) help = optdict.get('help') if help: help = normalize_text(help, line_len=79, indent='# ') print(file=stream) print(_encode(help, encoding), file=stream) else: print(file=stream) if value is None: print('#%s=' % optname, file=stream) else: value = _encode(value, encoding).strip() print('%s=%s' % (optname, value), file=stream)
def ini_format(stream, options, encoding): """format options using the INI format""" for optname, optdict, value in options: value = format_option_value(optdict, value) help = optdict.get("help") if help: help = normalize_text(help, line_len=79, indent="# ") print >> stream print >> stream, _encode(help, encoding) else: print >> stream if value is None: print >> stream, "#%s=" % optname else: value = _encode(value, encoding).strip() print >> stream, "%s=%s" % (optname, value)
def ini_format_section(stream, section, options, encoding=None, doc=None): """format an options section using the INI format""" encoding = _get_encoding(encoding, stream) if doc: print >> stream, _encode(comment(doc), encoding) print >> stream, "[%s]" % section ini_format(stream, options, encoding)
def rest_format_section(stream, section, options, encoding=None, doc=None): """format an options section using as ReST formatted output""" encoding = _get_encoding(encoding, stream) if section: print('%s\n%s' % (section, "'"*len(section)), file=stream) if doc: print(_encode(normalize_text(doc, line_len=79, indent=''), encoding), file=stream) print(file=stream) for optname, optdict, value in options: help = optdict.get('help') print(':%s:' % optname, file=stream) if help: help = normalize_text(help, line_len=79, indent=' ') print(_encode(help, encoding), file=stream) if value: value = _encode(format_option_value(optdict, value), encoding) print(file=stream) print(' Default: ``%s``' % value.replace("`` ", "```` ``"), file=stream)
def rest_format_section(stream, section, options, encoding=None, doc=None): """format an options section using the INI format""" encoding = _get_encoding(encoding, stream) if section: print >> stream, "%s\n%s" % (section, "'" * len(section)) if doc: print >> stream, _encode(normalize_text(doc, line_len=79, indent=""), encoding) print >> stream for optname, optdict, value in options: help = optdict.get("help") print >> stream, ":%s:" % optname if help: help = normalize_text(help, line_len=79, indent=" ") print >> stream, _encode(help, encoding) if value: value = _encode(format_option_value(optdict, value), encoding) print >> stream, "" print >> stream, " Default: ``%s``" % value.replace("`` ", "```` ``")
def ini_format(stream, options, encoding): """format options using the INI format""" for optname, optdict, value in options: value = format_option_value(optdict, value) help = optdict.get('help') if help: help = normalize_text(help, line_len=79, indent='# ') print(file=stream) print(_encode(help, encoding), file=stream) else: print(file=stream) if value is None: print('#%s=' % optname, file=stream) else: value = _encode(value, encoding).strip() if optdict.get('type') == 'string' and '\n' in value: prefix = '\n ' value = prefix + prefix.join(value.split('\n')) print('%s=%s' % (optname, value), file=stream)
def ini_format(stream: Union[StringIO, TextIOWrapper], options: Any, encoding: str) -> None: """format options using the INI format""" for optname, optdict, value in options: value = format_option_value(optdict, value) help = optdict.get("help") if help: help = normalize_text(help, line_len=79, indent="# ") print(file=stream) print(_encode(help, encoding), file=stream) else: print(file=stream) if value is None: print("#%s=" % optname, file=stream) else: value = _encode(value, encoding).strip() if optdict.get("type") == "string" and "\n" in value: prefix = "\n " value = prefix + prefix.join(value.split("\n")) print("%s=%s" % (optname, value), file=stream)
def ini_format_section( stream: Union[StringIO, TextIOWrapper], section: str, options: Any, encoding: str = None, doc: Optional[Any] = None, ) -> None: """format an options section using the INI format""" encoding = _get_encoding(encoding, stream) if doc: print(_encode(comment(doc), encoding), file=stream) print("[%s]" % section, file=stream) ini_format(stream, options, encoding)