From 1a096b53bc67433e3ae83215277b4ea7b392910d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 5 Aug 2022 07:03:35 +0200 Subject: [PATCH] Fix: xml exports double quote --- app/scodoc/sco_formations.py | 12 ++++++------ app/scodoc/sco_utils.py | 4 ++-- .../formations/scodoc_formation_RT_BUT_RT_v1.xml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index 8128021f7..e8aa9b964 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -183,18 +183,18 @@ def formation_import_xml(doc: str, import_tags=True): # log("formation_import_xml: doc=%s" % doc) try: dom = xml.dom.minidom.parseString(doc) - except: + except Exception as exc: log("formation_import_xml: invalid XML data") - raise ScoValueError("Fichier XML invalide") + raise ScoValueError("Fichier XML invalide") from exc try: f = dom.getElementsByTagName("formation")[0] # or dom.documentElement D = sco_xml.xml_to_dicts(f) - except: + except Exception as exc: raise ScoFormatError( """Ce document xml ne correspond pas à un programme exporté par ScoDoc. (élément 'formation' inexistant par exemple).""" - ) + ) from exc assert D[0] == "formation" F = D[1] # F_quoted = F.copy() @@ -213,14 +213,14 @@ def formation_import_xml(doc: str, import_tags=True): res = cursor.fetchall() try: version = int(res[0][0]) + 1 - except: + except (ValueError, IndexError, TypeError): version = 1 F["version"] = version # create formation # F_unquoted = F.copy() # unescape_html_dict(F_unquoted) formation_id = sco_edit_formation.do_formation_create(F) - log("formation %s created" % formation_id) + log(f"formation {formation_id} created") ues_old2new = {} # xml ue_id : new ue_id modules_old2new = {} # xml module_id : new module_id # (nb: mecanisme utilise pour cloner semestres seulement, pas pour I/O XML) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 2087a141e..6f133fe17 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -704,7 +704,7 @@ def sendXML( tagname=None, force_outer_xml_tag=True, attached=False, - quote=True, + quote=False, filename=None, ): if type(data) != list: @@ -724,7 +724,7 @@ def sendResult( format=None, force_outer_xml_tag=True, attached=False, - quote_xml=True, + quote_xml=False, filename=None, ): if (format is None) or (format == "html"): diff --git a/tests/ressources/formations/scodoc_formation_RT_BUT_RT_v1.xml b/tests/ressources/formations/scodoc_formation_RT_BUT_RT_v1.xml index dd4bd01be..7d3c03275 100644 --- a/tests/ressources/formations/scodoc_formation_RT_BUT_RT_v1.xml +++ b/tests/ressources/formations/scodoc_formation_RT_BUT_RT_v1.xml @@ -1,5 +1,5 @@ - +