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-04 04:05:09 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-11-04 04:05:09 (GMT)
commitd83ce5730c43b80660a8ccd42bf5c145409dee9d (patch)
tree502c2ad60baea7c95037ea7e53f3deac045b3e7e /TurtleArt/taexportpython.py
parent11e09994d89396ddfa4f551a7194151320874367 (diff)
pyflakes, pep8 cleanup
Diffstat (limited to 'TurtleArt/taexportpython.py')
-rw-r--r--TurtleArt/taexportpython.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index c7d903d..1ed1ac5 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -32,8 +32,8 @@ import util.codegen as codegen
from talogo import LogoCode
from taprimitive import (ast_yield_true, Primitive, PyExportError,
value_to_ast)
-from tautils import (debug_output, find_group, find_top_block, get_stack_name)
-from tawindow import (global_objects, plugins_in_use)
+from tautils import (find_group, find_top_block, get_stack_name)
+from tawindow import plugins_in_use
_SETUP_CODE_START = """\
@@ -82,7 +82,6 @@ ACTION["%s"] = %s
PAT_IDENTIFIER_ILLEGAL_CHAR = re.compile("[^A-Za-z0-9_]")
-
def save_python(tw):
""" Find all the action stacks and turn each into Python code """
all_blocks = tw.just_blocks()
@@ -105,6 +104,7 @@ def save_python(tw):
snippets.append(_SETUP_CODE_END)
return "".join(snippets)
+
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") """
@@ -119,7 +119,6 @@ def _action_stack_to_python(block, tw, name="start"):
if not ast_list or not isinstance(ast_list[-1], ast.Yield):
ast_list.append(ast_yield_true())
action_stack_ast = ast.Module(body=ast_list)
- #debug_output(str(action_stack_ast))
# serialize the ASTs into python code
generated_code = codegen.to_source(action_stack_ast)
@@ -138,13 +137,14 @@ def _action_stack_to_python(block, tw, name="start"):
else:
newline = linesep
snippets = [_ACTION_STACK_START % (name_id),
- pre_preamble,
- _ACTION_STACK_PREAMBLE,
- generated_code,
- newline,
- _ACTION_STACK_END % (name, name_id)]
+ pre_preamble,
+ _ACTION_STACK_PREAMBLE,
+ generated_code,
+ newline,
+ _ACTION_STACK_END % (name, name_id)]
return "".join(snippets)
+
def _walk_action_stack(top_block, lc, convert_me=True):
""" Turn a stack of blocks into a list of ASTs
convert_me -- convert values and Primitives to ASTs or return them
@@ -241,6 +241,7 @@ def _walk_action_stack(top_block, lc, convert_me=True):
return ast_list
+
def _make_identifier(name):
""" Turn name into a Python identifier name by replacing illegal
characters """
@@ -250,6 +251,7 @@ def _make_identifier(name):
replaced = "_" + replaced
return replaced
+
def _indent(code, num_levels=1):
""" Indent each line of code with num_levels * 4 spaces
code -- some python code as a (multi-line) string """