throw ValueError when requesting unknown hash types
This commit is contained in:
parent
69ecfce9ff
commit
7210a9d0b1
1 changed files with 7 additions and 5 deletions
|
@ -18,12 +18,14 @@ def resolve(fname: str, esum: Optional[str] = None, cstype: str = ""):
|
|||
If neither is applicable it defaults to CRC32.
|
||||
"""
|
||||
cstype = cstype.upper()
|
||||
if cstype != "":
|
||||
if cstype in CKTYPES:
|
||||
if esum is None and (match := CKTYPES[cstype].REGEX.search(fname)):
|
||||
esum = match.group(0)
|
||||
return CKTYPES[cstype](), esum
|
||||
raise ValueError(f"Unknown checksum type: {cstype}")
|
||||
|
||||
for cstname, csclass in CKTYPES.items():
|
||||
for csclass in CKTYPES.values():
|
||||
if match := csclass.REGEX.search(fname):
|
||||
if esum is None:
|
||||
esum = match.group(0)
|
||||
|
|
Loading…
Reference in a new issue