diff options
author | Marion <marion.zepf@gmail.com> | 2013-08-16 09:49:20 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-08-16 09:49:20 (GMT) |
commit | 7d97ef90f223f4f3980f355dc3e9d39b8b8ee7c5 (patch) | |
tree | ad6fc6fc3c30309ac641c4cb2a8ce4ee4d032609 /TurtleArt/tautils.py | |
parent | a4456ea4b6b346bca7ea632a19daba46849dadfc (diff) |
use a utility function to get the name of a stack from the blocks
Diffstat (limited to 'TurtleArt/tautils.py')
-rw-r--r-- | TurtleArt/tautils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index 244be6d..a8ef384 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -808,6 +808,26 @@ def find_blk_below(blk, namelist): return None +def get_stack_name(blk): + ''' Return the name of the action stack that the given block belongs to. + If the top block of this stack is not a stack-defining block, return + None. ''' + top_block = find_top_block(blk) + if top_block.name == 'start': + return 'start' + elif top_block.name == 'hat1': + return 'stack1' + elif top_block.name == 'hat2': + return 'stack2' + elif top_block.name == 'hat': + try: + return top_block.connections[1].values[0] + except (IndexError, AttributeError): + return None + else: + return None + + def get_hardware(): ''' Determine whether we are using XO 1.0, 1.5, ... or 'unknown' hardware ''' |