1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/usr/bin/env python3
# Filters traceback lines from stdin.
import io
import sys
# Prevent \r from being inserted on Windows.
sys.stdout = io.TextIOWrapper(
sys.stdout.buffer,
sys.stdout.encoding,
sys.stdout.errors,
newline="\n",
line_buffering=sys.stdout.line_buffering,
)
in_tb = False
for line in sys.stdin:
do_print = not in_tb
if line.startswith('Traceback '):
in_tb = True
elif not line.startswith(' '):
in_tb = False
do_print = True
if do_print:
print(line, end='')
|