rust/src/etc/indenter

20 lines
366 B
Plaintext
Raw Normal View History

2015-01-15 02:23:46 -06:00
#!/usr/bin/env python
import re
import sys
2012-04-05 22:59:07 -05:00
2015-01-15 02:23:46 -06:00
indent = 0
more_re = re.compile(r"^rust: ~\">>")
less_re = re.compile(r"^rust: ~\"<<")
while True:
line = sys.stdin.readline()
if not line:
break
2012-04-05 22:59:07 -05:00
2015-01-15 02:23:46 -06:00
if more_re.match(line):
indent += 1
2012-04-21 12:04:58 -05:00
2015-01-15 02:23:46 -06:00
print "%03d %s%s" % (indent, " " * indent, line.strip())
if less_re.match(line):
indent -= 1