Fixed defaults

This commit is contained in:
itec78 2020-08-31 18:21:24 +02:00
parent b91da15172
commit 0e77ec5ae1
4 changed files with 21 additions and 10 deletions

View file

@ -1,6 +1,12 @@
#!/usr/bin/env python3
def dec2banana(num, dictstart = 0, shiftend = 0, minlength = 0, dictionary = [list("bcdfglmnprstvz"), list("aeiou")]):
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")]
numdict = len(dictionary)
v = num
st = ""
@ -17,7 +23,12 @@ def dec2banana(num, dictstart = 0, shiftend = 0, minlength = 0, dictionary = [li
return(st)
def banana2dec(banana, dictstart = 0, shiftend = 0, dictionary = [list("bcdfglmnprstvz"), list("aeiou")] ):
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")
numdict = len(dictionary)
v = 0
for i in range(len(banana)):

View file

@ -5,9 +5,9 @@ import banana
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert banana string to dec")
parser.add_argument("banana", help="String to be converted")
parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+', default=[list("bcdfglmnprstvz"), list("aeiou")]) # , list("123456")
parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0)
parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0)
parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+')
parser.add_argument("--dictstart", help="Set starting dictionary", type=int)
parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int)
args = parser.parse_args()
print(banana.banana2dec(args.banana, args.dictstart, args.shiftend, args.dictionary))

View file

@ -5,7 +5,7 @@ import banana
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert dec number to banana")
parser.add_argument("num", help="number to be converted", type=int)
parser.add_argument("--minlength", help="Set minimum length", type=int, default=0)
parser.add_argument("--minlength", help="Set minimum length", type=int)
args = parser.parse_args()
print(banana.dec2banana(args.num, 1, 0, args.minlength))

View file

@ -5,10 +5,10 @@ import banana
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert dec number to banana")
parser.add_argument("num", help="number to be converted", type=int)
parser.add_argument("--dictstart", help="Set starting dictionary", type=int, default=0)
parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int, default=0)
parser.add_argument("--minlength", help="Set minimum length", type=int, default=0)
parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+', default=[list("bcdfglmnprstvz"), list("aeiou")]) # , list("123456")
parser.add_argument("--dictstart", help="Set starting dictionary", type=int)
parser.add_argument("--shiftend", help="Set shift for ending dictionary", type=int)
parser.add_argument("--minlength", help="Set minimum length", type=int)
parser.add_argument("--dictionary", help="Set dictionary", type=list, nargs='+')
args = parser.parse_args()
print(banana.dec2banana(args.num, args.dictstart, args.shiftend, args.minlength, args.dictionary))