Skip to content

Instantly share code, notes, and snippets.

@fishy
Created December 20, 2013 21:07
Show Gist options
  • Save fishy/8061555 to your computer and use it in GitHub Desktop.
Save fishy/8061555 to your computer and use it in GitHub Desktop.
import sys
last_line = ''
for line in sys.stdin.xreadlines():
length = len(last_line.rstrip())
if length != len(line.rstrip()) or length == 0:
sys.stdout.write(last_line)
last_line = line
continue
if line.count("=") == length:
last_line = "= " + last_line
elif line.count("-") == length:
if last_line.startswith("GERRIT") or last_line.startswith("SEARCHBOX"):
sys.stdout.write(last_line)
last_line = line
else:
last_line = "== " + last_line
elif line.count("~") == length:
last_line = "=== " + last_line
elif line.count("^") == length:
last_line = "==== " + last_line
elif line.count("+") == length:
last_line = "===== " + last_line
else:
sys.stdout.write(last_line)
last_line = line
sys.stdout.write(last_line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment