|
|
|
@ -2,22 +2,17 @@
|
|
|
|
|
|
|
|
|
|
import vim
|
|
|
|
|
import re
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
def dec2banana(num, dictstart = None, shiftend = None, minlength = None, dictionary = None):
|
|
|
|
|
#defaults
|
|
|
|
|
if dictstart is None: dictstart = 0
|
|
|
|
|
if shiftend is None: shiftend = 0
|
|
|
|
|
if minlength is None: minlength = 0
|
|
|
|
|
if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dec2banana(num):
|
|
|
|
|
dictionary = [list("bcdfglmnprstvz"), list("aeiou")]
|
|
|
|
|
numdict = len(dictionary)
|
|
|
|
|
|
|
|
|
|
v = num
|
|
|
|
|
st = ""
|
|
|
|
|
l = 0
|
|
|
|
|
|
|
|
|
|
i = (numdict - 1 + dictstart + shiftend) % numdict
|
|
|
|
|
while not (v == 0 and i == (numdict - 1 + dictstart) % numdict and l >= minlength):
|
|
|
|
|
i = (numdict - 1) % numdict
|
|
|
|
|
while not (v == 0 and i == (numdict - 1) % numdict and l >= 0):
|
|
|
|
|
r = v % len(dictionary[i])
|
|
|
|
|
v = int(v / len(dictionary[i]))
|
|
|
|
|
st = dictionary[i][r] + st
|
|
|
|
@ -27,18 +22,15 @@ def dec2banana(num, dictstart = None, shiftend = None, minlength = None, diction
|
|
|
|
|
return(st)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def banana2dec(banana, dictstart = None, shiftend = None, dictionary = None):
|
|
|
|
|
#defaults
|
|
|
|
|
if dictstart is None: dictstart = 0
|
|
|
|
|
if shiftend is None: shiftend = 0
|
|
|
|
|
if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] #, list("123456")
|
|
|
|
|
def banana2dec(banana):
|
|
|
|
|
dictionary = [list("bcdfglmnprstvz"), list("aeiou")]
|
|
|
|
|
|
|
|
|
|
numdict = len(dictionary)
|
|
|
|
|
if (len(banana) - shiftend) % numdict != 0:
|
|
|
|
|
if len(banana) % numdict != 0:
|
|
|
|
|
return("Banana non valida")
|
|
|
|
|
v = 0
|
|
|
|
|
for i in range(len(banana)):
|
|
|
|
|
r = (numdict + i + dictstart) % numdict
|
|
|
|
|
r = (numdict + i) % numdict
|
|
|
|
|
try:
|
|
|
|
|
v = v * len(dictionary[r]) + dictionary[r].index(banana[i])
|
|
|
|
|
except:
|
|
|
|
@ -46,17 +38,14 @@ def banana2dec(banana, dictstart = None, shiftend = None, dictionary = None):
|
|
|
|
|
|
|
|
|
|
return(v)
|
|
|
|
|
|
|
|
|
|
def isbanana(banana, dictstart = None, shiftend = None, dictionary = None):
|
|
|
|
|
#defaults
|
|
|
|
|
if dictstart is None: dictstart = 0
|
|
|
|
|
if shiftend is None: shiftend = 0
|
|
|
|
|
if dictionary is None: dictionary = [list("bcdfglmnprstvz"), list("aeiou")] #, list("123456")
|
|
|
|
|
|
|
|
|
|
def isbanana(banana):
|
|
|
|
|
dictionary = [list("bcdfglmnprstvz"), list("aeiou")] #, list("123456")
|
|
|
|
|
numdict = len(dictionary)
|
|
|
|
|
if (len(banana) - shiftend) % numdict != 0:
|
|
|
|
|
|
|
|
|
|
if len(banana) % numdict != 0:
|
|
|
|
|
return(False)
|
|
|
|
|
for i in range(len(banana)):
|
|
|
|
|
r = (numdict + i + dictstart) % numdict
|
|
|
|
|
r = (numdict + i) % numdict
|
|
|
|
|
if banana[i] not in dictionary[r]:
|
|
|
|
|
return(False)
|
|
|
|
|
|
|
|
|
@ -66,8 +55,7 @@ def callback(x):
|
|
|
|
|
return "%s" % dec2banana(int(x[0], base=10)).upper()
|
|
|
|
|
|
|
|
|
|
def text2banana(text):
|
|
|
|
|
text = re.sub(r"[0-9][0-9]*",callback,text)
|
|
|
|
|
return text
|
|
|
|
|
return re.sub(r"[0-9][0-9]*",callback,text)
|
|
|
|
|
|
|
|
|
|
def callback_dec(x):
|
|
|
|
|
b = x[0].strip().lower()
|
|
|
|
@ -77,8 +65,7 @@ def callback_dec(x):
|
|
|
|
|
return x[0]
|
|
|
|
|
|
|
|
|
|
def text2dec(text):
|
|
|
|
|
text = re.sub(r"[A-Z][A-Z]*",callback_dec,text)
|
|
|
|
|
return text
|
|
|
|
|
return re.sub(r"[A-Z][A-Z]*",callback_dec,text)
|
|
|
|
|
|
|
|
|
|
def get_selected_text():
|
|
|
|
|
buf = vim.current.buffer
|
|
|
|
|