diff --git a/text2banana.py b/text2banana.py new file mode 100755 index 0000000..3fc3fe2 --- /dev/null +++ b/text2banana.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import argparse +import re +import sys + +import banana + + +def callback(x): + return " %s " % banana.dec2banana(int(x[0], base=10)).upper() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Convert a text from dec to uppercase banana" + ) + args = parser.parse_args() + text = sys.stdin.read() + text = re.sub(r"[0-9][0-9]*", callback, text) + sys.stdout.write(text) diff --git a/text2dec.py b/text2dec.py new file mode 100755 index 0000000..821b144 --- /dev/null +++ b/text2dec.py @@ -0,0 +1,23 @@ +#!/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)