Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-12 23:59:19 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-12 23:59:19 (GMT)
commitad1e45ec20eeef32bebca6c12e90c39dfb8adeac (patch)
treef1475f8890e940b5afd12a8defeb34077ee2beda
parent3d725845c08fe0897ade3bcd6b86c654ab8d5228 (diff)
remove obsolete utility function ast_to_value()
- Its functionality is now provided by tatype.get_type().
-rw-r--r--TurtleArt/taprimitive.py26
1 files changed, 5 insertions, 21 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index ec30e6c..dafe781 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -464,9 +464,12 @@ class Primitive(object):
ast_list.append(new_ast)
return ast_list
- # comments
+ # comment
elif self == Primitive.comment:
- text = ' ' + str(ast_to_value(new_arg_asts[0]))
+ if isinstance(new_arg_asts[0], ast.Str):
+ text = ' ' + str(new_arg_asts[0].s)
+ else:
+ text = ' ' + str(new_arg_asts[0])
return ast_extensions.Comment(text)
# heap
@@ -1083,25 +1086,6 @@ def value_to_ast(value, *args_for_prim, **kwargs_for_prim):
else:
raise ValueError("unknown type of raw value: " + repr(type(value)))
-def ast_to_value(ast_object): # TODO make obsolete and remove
- """ Retrieve the value out of a value AST. Supported AST types:
- Num, Str, Name, List, Tuple, Set
- If no value can be extracted, return None. """
- if not isinstance(ast_object, ast.AST):
- return ast_object
- elif isinstance(ast_object, ast.Num):
- return ast_object.n
- elif isinstance(ast_object, ast.Str):
- return ast_object.s
- elif isinstance(ast_object, (ast.List, ast.Tuple, ast.Set)):
- return ast_object.elts
- elif (isinstance(ast_object, ast.Name)):
- try:
- return eval(ast_object.id)
- except NameError:
- return None
- else:
- return None
def ast_yield_true():
return ast.Yield(value=ast.Name(id='True', ctx=ast.Load))