From 0a000afba4d07ccfcb645a72a1aeb025f313a71b Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Fri, 3 Dec 2021 10:46:14 +0100 Subject: [PATCH] soften xml formation element --- app/scodoc/sco_formations.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index afdcbaee2..b5744cc32 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -180,8 +180,14 @@ def formation_import_xml(doc: str, import_tags=True): log("formation_import_xml: invalid XML data") raise ScoValueError("Fichier XML invalide") - f = dom.getElementsByTagName("formation")[0] # or dom.documentElement - D = sco_xml.xml_to_dicts(f) + try: + f = dom.getElementsByTagName("formation")[0] # or dom.documentElement + D = sco_xml.xml_to_dicts(f) + except: + raise ScoValueError( + "Le document xml ne correspond pas à un programme BUT. (élément 'formation' inexistant " + "par exemple)." + ) assert D[0] == "formation" F = D[1] # F_quoted = F.copy()