ui: use match statement where practicable
This commit is contained in:
parent
305874a59c
commit
5463f60376
1 changed files with 17 additions and 17 deletions
34
mmgen/ui.py
34
mmgen/ui.py
|
|
@ -107,15 +107,15 @@ def keypress_confirm(
|
||||||
|
|
||||||
from .term import get_char
|
from .term import get_char
|
||||||
while True:
|
while True:
|
||||||
reply = get_char(prompt, immed_chars='yYnN').strip('\n\r')
|
match get_char(prompt, immed_chars='yYnN').strip('\n\r'):
|
||||||
if not reply:
|
case '':
|
||||||
msg_r(nl)
|
msg_r(nl)
|
||||||
return do_return(default_yes)
|
return do_return(default_yes)
|
||||||
elif reply in 'yYnN':
|
case 'y' | 'Y' | 'n' | 'N' as reply:
|
||||||
msg_r(nl)
|
msg_r(nl)
|
||||||
return do_return(reply in 'yY')
|
return do_return(reply in 'yY')
|
||||||
else:
|
case _:
|
||||||
msg_r('\nInvalid reply\n' if verbose else '\r')
|
msg_r('\nInvalid reply\n' if verbose else '\r')
|
||||||
|
|
||||||
def do_pager(text):
|
def do_pager(text):
|
||||||
|
|
||||||
|
|
@ -153,12 +153,12 @@ def do_license_msg(cfg, *, immed=False):
|
||||||
from .term import get_char
|
from .term import get_char
|
||||||
prompt = "Press 'w' for conditions and warranty info, or 'c' to continue: "
|
prompt = "Press 'w' for conditions and warranty info, or 'c' to continue: "
|
||||||
while True:
|
while True:
|
||||||
reply = get_char(prompt, immed_chars=('', 'wc')[bool(immed)])
|
match get_char(prompt, immed_chars=('', 'wc')[bool(immed)]):
|
||||||
if reply == 'w':
|
case 'w':
|
||||||
do_pager(gpl.conditions)
|
do_pager(gpl.conditions)
|
||||||
elif reply == 'c':
|
case 'c':
|
||||||
msg('')
|
msg('')
|
||||||
break
|
break
|
||||||
else:
|
case _:
|
||||||
msg_r('\r')
|
msg_r('\r')
|
||||||
msg('')
|
msg('')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue