16 lines
515 B
Python
16 lines
515 B
Python
from typing import Optional, Union
|
|
|
|
|
|
def normaliser_type_tiers(type_tiers: Union[str, int, None]) -> Optional[str]:
|
|
if type_tiers is None:
|
|
return None
|
|
|
|
mapping_int = {0: "client", 1: "fournisseur", 2: "prospect", 3: "all"}
|
|
|
|
if isinstance(type_tiers, int):
|
|
return mapping_int.get(type_tiers, "all")
|
|
|
|
if isinstance(type_tiers, str) and type_tiers.isdigit():
|
|
return mapping_int.get(int(type_tiers), "all")
|
|
|
|
return type_tiers.lower() if isinstance(type_tiers, str) else None
|