diff --git a/tools/align_from_ayoub.py b/tools/align_from_ayoub.py index e825c48..27bdf83 100644 --- a/tools/align_from_ayoub.py +++ b/tools/align_from_ayoub.py @@ -44,6 +44,34 @@ def clean(v): return s or None +# Labels iTop officiels pour normaliser les variantes Excel +ITOP_ENVS = ["Développement", "Intégration", "Pré-Prod", "Production", "Recette", "Test", "Formation"] + + +def norm_env(raw): + """Normalise 'production'/'Test 1'/'Preprod' vers les 7 labels iTop.""" + if not raw: + return None + s = raw.strip() + # Enleve suffixe numerique (Test 1 -> Test, Recette 2 -> Recette) + s = re.sub(r"\s+\d+$", "", s) + # Match exact + if s in ITOP_ENVS: + return s + # Match case-insensitive + variantes + low = s.lower().replace("-", "").replace(" ", "") + aliases = { + "developpement": "Développement", "dev": "Développement", + "integration": "Intégration", "int": "Intégration", + "preprod": "Pré-Prod", "preproduction": "Pré-Prod", + "prod": "Production", "production": "Production", + "recette": "Recette", "rec": "Recette", + "test": "Test", "tests": "Test", + "formation": "Formation", + } + return aliases.get(low) + + def slugify(s, maxlen=10): """Slug ASCII lowercase pour code (domain.code varchar(10)).""" if not s: @@ -161,7 +189,8 @@ def main(): hostname = hostname.split(".")[0].lower() dom_name = clean(row[idx_dom]) if idx_dom >= 0 and idx_dom < len(row) else None - env_name = clean(row[idx_env]) if idx_env >= 0 and idx_env < len(row) else None + env_raw = clean(row[idx_env]) if idx_env >= 0 and idx_env < len(row) else None + env_name = norm_env(env_raw) # Normalisation vers 7 labels iTop resp = clean(row[idx_resp]) if idx_resp >= 0 and idx_resp < len(row) else None ref = clean(row[idx_ref]) if idx_ref >= 0 and idx_ref < len(row) else None if resp: