Unverified Commit 8237675e authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

enforce str type on duration input

parent fd334409
Pipeline #18010 passed with stages
in 1 minute and 56 seconds
......@@ -234,16 +234,16 @@ def _has_http_locator(digital_object) -> bool:
def _normalize_duration(duration) -> int:
if re.fullmatch(r'\d+:\d{2}', duration, re.ASCII):
if re.fullmatch(r'\d+:\d{2}', str(duration), re.ASCII):
split = duration.split(':')
return int(split[0]) * 60 + int(split[1])
elif re.fullmatch(r'\d+:\d{2}:\d{2}', duration, re.ASCII):
elif re.fullmatch(r'\d+:\d{2}:\d{2}', str(duration), re.ASCII):
split = duration.split(':')
return int(split[0]) * 3600 + int(split[1]) * 60 + int(split[2])
elif re.fullmatch(r'\d+:\d{2}:\d{2}\d{3}', duration, re.ASCII):
elif re.fullmatch(r'\d+:\d{2}:\d{2}\d{3}', str(duration), re.ASCII):
split = duration.split(':')
return int(split[0]) * 3600 + int(split[1]) * 60 + int(split[2])
elif re.fullmatch(r'\d+.\d{6}', duration, re.ASCII):
elif re.fullmatch(r'\d+.\d{6}', str(duration), re.ASCII):
return int(duration.split('.')[0])
else:
logging.warning(f'Can\'t parse duration `{duration}`')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment