conversione interi testi #1

Merged
itec merged 1 commit from boyska/banana:master into master 2020-09-24 01:39:39 +02:00
2 changed files with 43 additions and 0 deletions

20
text2banana.py Executable file
View file

@ -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)

23
text2dec.py Executable file
View file

@ -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)