tests/filtercr.py
author Mads Kiilerich <mads@kiilerich.com>
Sat, 06 Aug 2011 23:52:20 +0200
branchstable
changeset 15065 24a6c3f903bb
parent 13141 6cfe17c19ba2
permissions -rwxr-xr-x
util: wrap lines with multi-byte characters correctly (issue2943) This re-introduces the unicode conversion what was lost in d320e70442a5 5 years ago and had the comment: To avoid corrupting multi-byte characters in line, we must wrap a Unicode string instead of a bytestring.

#!/usr/bin/env python

# Filter output by the progress extension to make it readable in tests

import sys, re

for line in sys.stdin:
    line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line)
    sys.stdout.write(line)
print