Commit 7dc739b1 authored by Samuel GAIST's avatar Samuel GAIST

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

Empty as in "{}"
parent ff274835
......@@ -118,14 +118,14 @@ class SimpleToolchainPreview(QWidget):
with graph.subgraph(name="cluster_datasets") as dg:
for block in json_object["datasets"]:
for block in json_object.get("datasets", []):
name, label = build_block_table(block, DATASET_COLOR)
dg.node(name=name, label=label)
with graph.subgraph(name="cluster_blocks") as bg:
for block in json_object["blocks"]:
for block in json_object.get("blocks", []):
name, label = build_block_table(block, BLOCK_COLOR)
bg.node(name=name, label=label)
......@@ -150,13 +150,13 @@ class SimpleToolchainPreview(QWidget):
with graph.subgraph(name="cluster_analyzers") as ag:
for block in json_object["analyzers"]:
for block in json_object.get("analyzers", []):
name, label = build_block_table(block, ANALYZER_COLOR)
ag.node(name=name, label=label)
channel_colors = json_object["representation"]["channel_colors"]
channel_colors = json_object.get("representation", {}).get("channel_colors", {})
for connection in json_object["connections"]:
for connection in json_object.get("connections", []):
from_block, output = connection["from"].split(".")
to_block, input_ = connection["to"].split(".")
channel_color = channel_colors.get(connection["channel"], "black")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment