Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/taexportpython.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-11-01 00:11:13 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-11-01 00:11:13 (GMT)
commitd0b3ef4fe54c58efae577f96fc3c799a649fec2b (patch)
tree6c5a210fa8a098b30aece4b5f8bd099514fc13d0 /TurtleArt/taexportpython.py
parent8ff90d1725fee8dcd4a6e51e2001ccab916501ac (diff)
need a way to get global_objects
Diffstat (limited to 'TurtleArt/taexportpython.py')
-rw-r--r--TurtleArt/taexportpython.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index 99084f0..49bde06 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -66,6 +66,7 @@ def %s():
"""
_START_STACK_START_ADD = """\
tw.start_plugins()
+ global_objects = tw.get_global_objects()
"""
_ACTION_STACK_PREAMBLE = """\
turtles = tw.turtles
@@ -98,22 +99,23 @@ def save_python(tw):
for block in tops_of_stacks:
stack_name = get_stack_name(block)
if stack_name:
- pythoncode = _action_stack_to_python(block, tw.lc, name=stack_name)
+ pythoncode = _action_stack_to_python(block, tw, name=stack_name)
snippets.append(pythoncode)
snippets.append(linesep)
snippets.append(_SETUP_CODE_END)
return "".join(snippets)
-def _action_stack_to_python(block, lc, name="start"):
+def _action_stack_to_python(block, tw, name="start"):
""" Turn a stack of blocks into Python code
name -- the name of the action stack (defaults to "start") """
+
if isinstance(name, int):
name = float(name)
if not isinstance(name, basestring):
name = str(name)
# traverse the block stack and get the AST for every block
- ast_list = _walk_action_stack(block, lc)
+ ast_list = _walk_action_stack(block, tw.lc)
if not isinstance(ast_list[-1], ast.Yield):
ast_list.append(ast_yield_true())
action_stack_ast = ast.Module(body=ast_list)