From 0fe27bae354a35d474021698dbf35c27f7b87e2f Mon Sep 17 00:00:00 2001 From: Philipp Fleischhacker Date: Tue, 30 Apr 2019 19:57:38 +0200 Subject: [PATCH] [STCC-189] skip blocks that have neither a parent nor a next block (#120) --- src/scratchtocatrobat/scratch/scratch3.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/scratchtocatrobat/scratch/scratch3.py b/src/scratchtocatrobat/scratch/scratch3.py index df1cc3ad..8036cf83 100644 --- a/src/scratchtocatrobat/scratch/scratch3.py +++ b/src/scratchtocatrobat/scratch/scratch3.py @@ -170,9 +170,11 @@ def parse_sprite(self, sprite): return scratch2ProjectDict def build_block_structure(self, blockId, temp_block_dict): - block = temp_block_dict[blockId] - if block.nextName is not None: - block.nextBlock = temp_block_dict[block.nextName] - if block.parentName is not None: - block.parentBlock = temp_block_dict[block.parentName] - + try: + block = temp_block_dict[blockId] + if block.nextName is not None: + block.nextBlock = temp_block_dict[block.nextName] + if block.parentName is not None: + block.parentBlock = temp_block_dict[block.parentName] + except KeyError as ex: + log.warn("Block: " + ex.message + " does not exist in the block dictionary.") \ No newline at end of file