baseconv: use match statement where practicable

This commit is contained in:
The MMGen Project 2025-09-23 09:20:54 +00:00
commit e29c464ebb
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2

View file

@ -124,14 +124,17 @@ class baseconv:
def do_die():
die('BaseConversionPadError', f"{pad!r}: illegal value for 'pad' (must be None, 'seed' or int)")
if pad is None:
return 0
elif type(pad) is int:
return pad
elif pad == 'seed':
return seed_pad_func()
else:
do_die()
match pad:
case None:
return 0
case bool():
do_die()
case int():
return pad
case 'seed':
return seed_pad_func()
case _:
do_die()
def tohex(self, words_arg, /, *, pad=None):
"convert string or list data of instance base to a hexadecimal string"