Mercurial > libervia-backend
comparison sat/tools/xml_tools.py @ 3233:8770397f8f82
tools (xl_tools): fixed handling of list options labels
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 27 Mar 2020 09:50:42 +0100 |
parents | 559a625a236b |
children | 2b6f69f6df8c |
comparison
equal
deleted
inserted
replaced
3232:f3c99e96ac03 | 3233:8770397f8f82 |
---|---|
469 _("The 'options' tag is not allowed in parameter of type 'list'!") | 469 _("The 'options' tag is not allowed in parameter of type 'list'!") |
470 ) | 470 ) |
471 elems = param.getElementsByTagName("option") | 471 elems = param.getElementsByTagName("option") |
472 if len(elems) == 0: | 472 if len(elems) == 0: |
473 return [] | 473 return [] |
474 options = [elem.getAttribute("value") for elem in elems] | 474 options = [] |
475 for elem in elems: | |
476 value = elem.getAttribute("value") | |
477 if not value: | |
478 raise exceptions.InternalError("list option must have a value") | |
479 label = elem.getAttribute("label") | |
480 if label: | |
481 options.append((value, label)) | |
482 else: | |
483 options.append(value) | |
475 selected = [ | 484 selected = [ |
476 elem.getAttribute("value") | 485 elem.getAttribute("value") |
477 for elem in elems | 486 for elem in elems |
478 if elem.getAttribute("selected") == "true" | 487 if elem.getAttribute("selected") == "true" |
479 ] | 488 ] |