Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tautils.py
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-08-16 09:49:20 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-16 09:49:20 (GMT)
commit7d97ef90f223f4f3980f355dc3e9d39b8b8ee7c5 (patch)
treead6fc6fc3c30309ac641c4cb2a8ce4ee4d032609 /TurtleArt/tautils.py
parenta4456ea4b6b346bca7ea632a19daba46849dadfc (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.py20
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 '''