#!/usr/bin/python3 """Eliminate the chaff, output the wheat.""" import sys prev_mw_line = '' show = 0 for line in (raw_line.rstrip('\n') for raw_line in sys.stdin): if line.startswith('MW! '): prev_mw_line = line elif line.startswith('Caught signal'): show = 1 print() print(prev_mw_line) mw_prev_line = '' if show: print(line) if line.startswith('Done dumping'): mw_prev_line = '' show = 0 sys.stdout.flush()