diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-07-19 20:44:40 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-07-19 20:44:40 (GMT) |
commit | e350b3dd2ecaad2b08b6d3c5c62fd059cf675174 (patch) | |
tree | f898e8bfa1b6f306bd383f86866b73008e33b58d /plugins/turtle_blocks_extras | |
parent | a04bfea5aabfed5f07a0c70126afd891a5284808 (diff) |
more robust error checking for load_blocks
Diffstat (limited to 'plugins/turtle_blocks_extras')
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index d75e336..be44296 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -1447,8 +1447,11 @@ bullets')) x, y = self.tw.active_turtle.get_xy() if type(blkname) == type([]): name = blkname[0] - value = blkname[1:] - dy = int(self._find_block(name, x, y, value)) + if len(blkname) > 1: + value = blkname[1:] + dy = int(self._find_block(name, x, y, value)) + else: + dy = int(self._find_block(name, x, y)) else: name = blkname if name == 'delete': @@ -1466,10 +1469,13 @@ bullets')) def _make_block(self, name, x, y, defaults): x_pos = x + 20 y_pos = y + 20 - for i, v in enumerate(defaults): - if type(v) == float and int(v) == v: - defaults[i] = int(v) - self.tw._new_block(name, x_pos, y_pos, defaults) + if defaults is None: + self.tw._new_block(name, x_pos, y_pos, defaults) + else: + for i, v in enumerate(defaults): + if type(v) == float and int(v) == v: + defaults[i] = int(v) + self.tw._new_block(name, x_pos, y_pos, defaults) # Find the block we just created and attach it to a stack. self.tw.drag_group = None |