def warning_string(prefix='# ', width=80, srcfiles=set(), enforce_ascii=False):
    # type: (str, int, Iterable[str], bool) -> str
    """
	Generate UCR warning text.

	:param prefix: String to prepend before each line.
	:param width: Maximum line length. UNUSED.
	:param srcfiles: File names of source template.
	:param enforce_ascii: Transliterate Umlauts.
	:returns: A warning sting based on :py:const:`WARNING_TEXT`.
	"""
    res = []

    for line in WARNING_TEXT.splitlines():
        if enforce_ascii:
            line = replace_umlaut(line).encode('ascii', 'replace')
        res.append('%s%s' % (prefix, line))

    for srcfile in sorted(srcfiles):
        if enforce_ascii:
            srcfile = srcfile.encode('ascii', 'replace')
        res.append('%s\t%s' % (prefix, srcfile))
    res.append(prefix)

    return "\n".join(res)
Beispiel #2
0
def warning_string(prefix='# ', width=80, srcfiles=set(), enforce_ascii=False):
    """Generate UCR warning text."""
    res = []

    for line in WARNING_TEXT.splitlines():
        if enforce_ascii:
            line = replace_umlaut(line).encode('ascii', 'replace')
        res.append('%s%s' % (prefix, line))

    for srcfile in sorted(srcfiles):
        if enforce_ascii:
            srcfile = srcfile.encode('ascii', 'replace')
        res.append('%s\t%s' % (prefix, srcfile))
    res.append(prefix)

    return "\n".join(res)
Beispiel #3
0
def warning_string(prefix='# ', width=80, srcfiles=set(), enforce_ascii=False):
	"""Generate UCR warning text."""
	res = []

	for line in WARNING_TEXT.splitlines():
		if enforce_ascii:
			line = replace_umlaut(line).encode('ascii', 'replace')
		res.append('%s%s' % (prefix, line))

	for srcfile in sorted(srcfiles):
		if enforce_ascii:
			srcfile = srcfile.encode('ascii', 'replace')
		res.append('%s\t%s' % (prefix, srcfile))
	res.append(prefix)

	return "\n".join(res)