Commit 35bd358f authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI

[widgets][toolchaineditor] Make resistent to bad json

parent a36325c9
......@@ -748,21 +748,14 @@ class Toolchain(QWidget):
self.json_object = json_object
if "representation" in self.json_object:
self.web_representation = self.json_object["representation"]
else:
self.web_representation = None
if "editor_gui" in self.json_object:
self.editor_gui = self.json_object["editor_gui"]
else:
self.editor_gui = None
self.web_representation = self.json_object.get("representation")
self.editor_gui = self.json_object.get("editor_gui")
self.clear_space()
# Get datasets, blocks, analyzers
for block_type in BlockType:
for block_item in self.json_object[block_type.value]:
for block_item in self.json_object.get(block_type.value, {}):
block = Block(
block_type.name, self.block_config, self.connection_config
)
......@@ -780,8 +773,10 @@ class Toolchain(QWidget):
self.scene.addItem(block)
# Display connections
connections = self.json_object["connections"]
channel_colors = self.json_object["representation"]["channel_colors"]
connections = self.json_object.get("connections", [])
channel_colors = self.json_object.get("representation", {}).get(
"channel_colors"
)
for connection_item in connections:
connection = Connection(self.connection_config)
......
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