summaryrefslogtreecommitdiffstats
path: root/src/etc/indenter
blob: 21bfc448ae2b4a0c8b2ec4ede7d9285820365286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
import re
import sys

indent = 0
more_re = re.compile(r"^rust: ~\">>")
less_re = re.compile(r"^rust: ~\"<<")
while True:
    line = sys.stdin.readline()
    if not line:
        break

    if more_re.match(line):
        indent += 1

    print("%03d %s%s" % (indent, " " * indent, line.strip()))

    if less_re.match(line):
        indent -= 1