banana/text2dec.py
2020-09-24 01:29:17 +02:00

23 lines
475 B
Python
Executable file

#!/usr/bin/env python3
import argparse
import re
import sys
import banana
def callback(x):
b = x[0].strip().lower()
if banana.isbanana(b):
return "%s" % banana.banana2dec(b)
else:
return x[0]
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert a text from banana to dec")
args = parser.parse_args()
text = sys.stdin.read()
text = re.sub(r"[A-Z][A-Z]*", callback, text)
sys.stdout.write(text)