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-08 13:36:05 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-11-08 13:36:05 (GMT)
commit34d13acd6453f0bfea8ac0c55eec4b737bddea5c (patch)
treebe70abb167ff8ae798cdedb3d23f8b33645a0bf1 /TurtleArt/taexportpython.py
parent5c0fb4a31b17e085a90649fca47a37c53b8c7c83 (diff)
refactor handling of extra code in python export
Diffstat (limited to 'TurtleArt/taexportpython.py')
-rw-r--r--TurtleArt/taexportpython.py28
1 files changed, 0 insertions, 28 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index c3c8e84..1ed1ac5 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -123,13 +123,6 @@ def _action_stack_to_python(block, tw, name="start"):
# serialize the ASTs into python code
generated_code = codegen.to_source(action_stack_ast)
- # FIXME: there must be a better way to do this using the AST
- # patch code to include missing get_active_turtle() calls
- if generated_code.count('turtles.set_turtle') > 0:
- generated_code = _insert_extra_code(
- generated_code, 'turtles.set_turtle',
- 'turtle = turtles.get_active_turtle()\n')
-
# wrap the action stack setup code around everything
name_id = _make_identifier(name)
if name == 'start':
@@ -152,27 +145,6 @@ def _action_stack_to_python(block, tw, name="start"):
return "".join(snippets)
-def _insert_extra_code(generated_code, target, insert):
- """ Add extra code when needed """
- tmp_code = ''
- while target in generated_code:
- i = generated_code.index(target)
- if i == 0:
- indent = 0
- else:
- indent = 0
- while generated_code[i - 1 - indent] == ' ':
- indent += 1
- while generated_code[i] != '\n':
- i += 1
- i += 1 # include the newline
- tmp_code += generated_code[0:i]
- for j in range(indent):
- tmp_code += ' '
- tmp_code += insert
- generated_code = generated_code[i:]
- return tmp_code + generated_code
-
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