Commit ff274835 authored by Samuel GAIST's avatar Samuel GAIST

[widgets][protocoltemplateeditor] Make resistant to "empty" JSON

Empty as in "{}"
parent 44ea95e7
......@@ -156,11 +156,11 @@ class SetWidget(QWidget):
def load(self, json_data):
"""Load this widget with the content of json_data"""
self.name_lineedit.setText(json_data["name"])
outputs = json_data["outputs"]
self.name_lineedit.setText(json_data.get("name"))
outputs = json_data.get("outputs", {})
self.outputs_tablewidget.setRowCount(len(outputs))
row = 0
for name, type_ in json_data["outputs"].items():
for name, type_ in outputs.items():
name_item = QTableWidgetItem(name)
type_item = QTableWidgetItem(type_)
self.outputs_tablewidget.setItem(row, 0, name_item)
......@@ -261,7 +261,7 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
def __load_json(self, json_object):
"""Load the json object passed as parameter"""
for set_ in json_object["sets"]:
for set_ in json_object.get("sets", []):
set_widget = SetWidget(self.dataformat_model)
set_widget.load(set_)
self.scroll_widget.addWidget(set_widget)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment