diff options
author | Marion <marion.zepf@gmail.com> | 2013-08-16 13:19:53 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-08-16 13:19:53 (GMT) |
commit | 0a6a3deb566df8c7832b6181d03db55039200976 (patch) | |
tree | cd58f7098deffe957b017823d37fa2a03725f3c4 /TurtleArt/taexportpython.py | |
parent | 7d97ef90f223f4f3980f355dc3e9d39b8b8ee7c5 (diff) |
special handling for 'hat' and 'stack' blocks when exporting them
Diffstat (limited to 'TurtleArt/taexportpython.py')
-rw-r--r-- | TurtleArt/taexportpython.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py index c87757d..88a73a0 100644 --- a/TurtleArt/taexportpython.py +++ b/TurtleArt/taexportpython.py @@ -31,7 +31,7 @@ import util.codegen as codegen from talogo import LogoCode from taprimitive import (Primitive, PyExportError, value_to_ast) -from tautils import (debug_output, find_group, find_top_block) +from tautils import (debug_output, find_group, find_top_block, get_stack_name) @@ -93,10 +93,11 @@ def save_python(tw): snippets = [_SETUP_CODE_START] for block in tops_of_stacks: - # TODO name of action stack? - pythoncode = _action_stack_to_python(block, tw.lc) - snippets.append(pythoncode) - snippets.append(linesep) + stack_name = get_stack_name(block) + if stack_name: + pythoncode = _action_stack_to_python(block, tw.lc, name=stack_name) + snippets.append(pythoncode) + snippets.append(linesep) snippets.append(_SETUP_CODE_END) return "".join(snippets) @@ -164,7 +165,7 @@ def _walk_action_stack(top_block, lc): block=block) if isinstance(new_ast, (list, tuple)): ast_list.extend(new_ast) - else: + elif new_ast is not None: ast_list.append(new_ast) elif arg_asts: new_ast = ast.List(elts=arg_asts, ctx=ast.Load) |