changed bit ifelse() chain to a match/case

This commit is contained in:
2024-05-07 21:43:06 -04:00
parent 2bbe080275
commit c61128f54c
+19 -17
View File
@@ -94,43 +94,46 @@ def get_args(conf):
sys.exit()
elif a[0]=='-':
for b in a[1:]:
if b=='c':
conf.first_punct = True
elif b=="C":
match b:
case 'c':
conf.first_punt = True
case 'C':
conf.last_punct = True
elif b=="n":
case 'n':
conf.first_number = True
elif b=='N': # add number
case 'N': # add number
conf.last_number = True
elif b=='s':
case 's':
conf.padding = Padding.spaces
elif b=='S':
case 'S':
conf.padding = Padding.dots
elif b=='p':
case 'p':
conf.padding = Padding.punct
elif b=='P':
case 'P':
conf.padding = Padding.numbers
elif b=='k':
case 'k':
conf.padding = Padding.camel
elif b=='K':
case 'K':
conf.padding = Padding.snake
elif b=='M':
case 'M':
conf.capitalize = True
elif b=='X':
case 'X':
conf.capitalize = True
conf.last_punct = True
conf.last_number = True
conf.padding = Padding.dots
elif b=="a":
case 'a':
conf.use_conjunctions = True;
elif b=="L":
case 'L':
narg = narg + 1
if narg < nargs:
conf.target_len = toInt(sys.argv[narg],[12,66],rangeStr = "Sorry, I can't build phrases that long")
case _:
print(f">>> unexpected command option '{b}'")
else:
if narg < nargs:
conf.number = toInt(sys.argv[narg],[0,40],rangeStr = "Sorry, I can't print that many; try a smaller number") # pick off the number of phrases
narg = narg + 1
@@ -250,4 +253,3 @@ NEW PLAN
leet encoder a->4A e->3 i->I o->0 s->5$ t->7
"""