Files

12 lines
390 B
Python

def normalize_id(value) -> str:
if value is None:
return ""
text = str(value).strip().strip("\ufeff")
text = text.translate(str.maketrans("0123456789", "0123456789"))
text = "".join(text.split())
if text.endswith(".0") and text[:-2].isdigit():
text = text[:-2]
if not text or not text.isdigit():
return ""
return text