Projet

Général

Profil

0001-wcs-Improved-error-reporting-when-importing-a-file-o.patch

Corentin Séchet, 25 février 2022 16:55

Télécharger (1,99 ko)

Voir les différences:

Subject: [PATCH] wcs: Improved error reporting when importing a file of the
 wrong type (#62109)

 wcs/blocks.py    | 2 +-
 wcs/formdef.py   | 2 +-
 wcs/workflows.py | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
wcs/blocks.py
176 176
            tree = tree.getroot()
177 177

  
178 178
        if tree.tag != cls.xml_root_node:
179
            raise BlockdefImportError(_('Unexpected root node'))
179
            raise BlockdefImportError(_('The provided file isn\'t a block, but a %s)' % tree.tag))
180 180

  
181 181
        if include_id and tree.attrib.get('id'):
182 182
            blockdef.id = tree.attrib.get('id')
wcs/formdef.py
1351 1351
            tree = tree.getroot()
1352 1352

  
1353 1353
        if tree.tag != cls.xml_root_node:
1354
            raise FormdefImportError(_('Unexpected root node'))
1354
            raise FormdefImportError(_('The provided file isn\'t a form, but a %s)' % tree.tag))
1355 1355

  
1356 1356
        if include_id and tree.attrib.get('id'):
1357 1357
            formdef.id = tree.attrib.get('id')
wcs/workflows.py
851 851
        if not ET.iselement(tree):
852 852
            tree = tree.getroot()
853 853

  
854
        if tree.tag != 'workflow':
855
            raise WorkflowImportError(_('Not a workflow'))
854
        if tree.tag != cls.xml_root_node:
855
            raise WorkflowImportError(_('The provided file isn\'t a workflow, but a %s)' % tree.tag))
856 856

  
857 857
        if include_id and tree.attrib.get('id'):
858 858
            workflow.id = tree.attrib.get('id')
859
-