19 lines
520 B
Python
19 lines
520 B
Python
from re import search
|
|
from typing import Optional
|
|
from .crc32 import CRC32
|
|
|
|
CKTYPES = [
|
|
(CRC32)
|
|
]
|
|
|
|
def resolve(fname: str, esum: Optional[str] = None, cstype: Optional[str] = None):
|
|
"""
|
|
Checks fname input for checksum pattern and returns first match.
|
|
Can be overridden with cstype.
|
|
If neither is applicable the first possible checksum type will be returned.
|
|
"""
|
|
if esum is None and (match := CKTYPES[0].REGEX.search(fname)):
|
|
esum = match.group(0)
|
|
|
|
return CKTYPES[0](), esum
|