Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/taprimitive.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/taprimitive.py')
-rw-r--r--TurtleArt/taprimitive.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 956f50d..f969e96 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -452,6 +452,12 @@ class Primitive(object):
raise ValueError("Primitive.identity got unexpected number "
"of arguments (%d)" % (len(new_arg_asts)))
+ # constant
+ elif self == CONSTANTS.get:
+ return TypedSubscript(value=ast.Name(id='CONSTANTS', ctx=ast.Load),
+ slice_=ast.Index(value=new_arg_asts[0]),
+ return_type=self.return_type)
+
# group of Primitives or sandwich-clamp block
elif self in (Primitive.group, LogoCode.prim_clamp):
ast_list = []
@@ -1052,17 +1058,11 @@ def value_to_ast(value, *args_for_prim, **kwargs_for_prim):
ast_list.append(item_ast)
return ast.List(elts=ast_list, ctx=ast.Load)
elif isinstance(value, Color):
- if str(value) in CONSTANTS:
- # repr(str(value)) is necessary; it first converts the Color to a
- # string and then adds appropriate quotes around that string
- return ast.Name(id='CONSTANTS[%s]' % repr(str(value)),
- ctx=ast.Load)
- else:
- # call to the Color constructor with this object's values,
- # e.g., Color('red', 0, 50, 100)
- return get_call_ast('Color', [value.name, value.color,
- value.shade, value.gray],
- return_type=TYPE_COLOR)
+ # call to the Color constructor with this object's values,
+ # e.g., Color('red', 0, 50, 100)
+ return get_call_ast('Color', [value.name, value.color,
+ value.shade, value.gray],
+ return_type=TYPE_COLOR)
else:
raise ValueError("unknown type of raw value: " + repr(type(value)))