git @ Cat's Eye Technologies The-Dipple / master python / tr-iffic
master

Tree @master (Download .tar.gz)

tr-iffic @masterraw · history · blame

#!/usr/bin/env python
# encoding: UTF-8

# SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
# For more information, please refer to <https://unlicense.org/>
# SPDX-License-Identifier: Unlicense

import sys
import fileinput

MAP = {
  '>': '→',
  '<': '←',
  '^': '↑',
  'v': '↓',
}

for line in fileinput.input():
    if line.startswith("| ") or line.startswith("    "):
        for char in MAP:
            line = line.replace(char, MAP[char])
    sys.stdout.write(line)