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-08-31 22:17:07 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-31 22:17:07 (GMT)
commit16c88b1eeec8fab27f75c01faff111de026e0114 (patch)
treeed7808ecddf935708264e81b6d1d59c876fd831a
parent5052f0e75b77c279484a74393f4ff6c55a07af7d (diff)
remove unused code from tabasics and taprimitive
-rw-r--r--TurtleArt/tabasics.py34
-rw-r--r--TurtleArt/taprimitive.py91
2 files changed, 1 insertions, 124 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 8bb50e4..eda9958 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -135,9 +135,6 @@ class Palettes():
"check_number": Primitive(self.check_number,
return_type=TYPE_NUMBER, # TODO make this function obsolete (the return type is actually nonsense)
arg_descs=[ArgSlot(TYPE_OBJECT)], export_me=False),
- "convert_value_for_move": Primitive(self.convert_value_for_move,
- return_type=TYPE_NUMBER, # TODO make this function obsolete (the return type is actually nonsense)
- arg_descs=[ArgSlot(TYPE_OBJECT)], export_me=False),
"convert_for_cmp": Primitive(Primitive.convert_for_cmp,
constant_args={'decimal_point': self.tw.decimal_point}),
"convert_to_number": Primitive(Primitive.convert_to_number,
@@ -330,7 +327,6 @@ turtle (can be used in place of a number block)'),
label=['turtle'])
# Deprecated
- primitive_dictionary['move'] = self._prim_move
palette.add_block('setxy',
hidden=True,
style='basic-style-2arg',
@@ -1201,36 +1197,6 @@ variable'))
self.tw.lc.ireturn()
yield True
- def convert_value_for_move(self, value):
- ''' Perform type conversion and other preprocessing on the parameter,
- so it can be passed to the 'move' primitive. '''
- if value is None:
- return value
-
- def _convert_to_float(val):
- if not _num_type(val):
- raise logoerror("#notanumber")
- return float(val)
-
- if isinstance(value, (tuple, list)):
- (val1, val2) = value
- val1_float = _convert_to_float(val1)
- val2_float = _convert_to_float(val2)
- value_converted = (val1_float, val2_float)
- else:
- value_converted = _convert_to_float(value)
- return value_converted
-
- def _prim_move(self, cmd, value1, pendown=True,
- reverse=False):
- ''' Turtle moves by method specified in value1 '''
-
- value1_conv = self.convert_value_for_move(value1)
-
- cmd(value1_conv, pendown=pendown)
-
- self.after_move()
-
def after_move(self, *ignored_args, **ignored_kwargs):
''' Update labels after moving the turtle '''
if self.tw.lc.update_values:
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 2abfd78..6f31b8c 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -67,8 +67,6 @@ class Primitive(object):
'modulo': ast.Mod,
'power': ast.Pow,
'integer_division': ast.FloorDiv,
- 'bitwise_and': ast.BitAnd,
- 'bitwise_or': ast.BitOr,
'and_': ast.And,
'or_': ast.Or,
'not_': ast.Not,
@@ -401,8 +399,7 @@ class Primitive(object):
len(new_arg_asts)))
# type conversion # TODO remove when obsolete
- elif self in (Primitive.convert_for_cmp, Primitive.convert_to_number,
- Primitive.convert_for_plus):
+ elif self in (Primitive.convert_for_cmp, Primitive.convert_to_number):
return self.func(*new_arg_asts, **new_kwarg_asts)
# identity
@@ -413,15 +410,6 @@ class Primitive(object):
raise ValueError("Primitive.identity got unexpected number "
"of arguments (%d)" % (len(new_arg_asts)))
- # tuples
- elif self == Primitive.make_tuple:
- if not new_kwarg_asts:
- return ast.Tuple(elts=new_arg_asts, ctx=ast.Load)
- else:
- raise ValueError("tuple constructor (Primitive.make_tuple) "
- "got unexpected arguments: " +
- repr(new_kwarg_asts))
-
# group of Primitives
elif self == Primitive.group:
ast_list = []
@@ -512,12 +500,6 @@ class Primitive(object):
# Primitive to an AST
@staticmethod
- def make_tuple(*values):
- """ This method corresponds to a Python tuple consisting of the given
- values. """
- return tuple(values)
-
- @staticmethod
def controller_repeat(num):
""" Loop controller for the 'repeat' block """
for i in range(num):
@@ -586,67 +568,6 @@ class Primitive(object):
return return_val
@staticmethod
- def convert_for_plus(value1, value2):
- """ If at least one value is a string, convert both to a string.
- Otherwise, convert both to a number. (Colors are converted to an
- integer before they are converted to a string.) """
- convert_to_ast = False
- (value1_ast, value2_ast) = (None, None)
-
- if isinstance(value1, ast.AST):
- convert_to_ast = True
- value1_ast = value1
- value1 = ast_to_value(value1_ast)
- if isinstance(value2, ast.AST):
- value2_ast = value2
- value2 = ast_to_value(value2_ast)
-
- def _to_string(val, val_ast):
- """ Return strings as they are, convert Colors to an integer and
- then to a string, and convert everything else directly to a
- string. """
- val_conv = val
- val_conv_ast = val_ast
- if not isinstance(val, basestring):
- if isinstance(val, Color):
- conv_prim = Primitive(str, slot_wrappers={
- 0: Primitive(int)})
- else:
- conv_prim = Primitive(str)
- if not convert_to_ast:
- val_conv = conv_prim(val)
- else:
- val_conv_ast = conv_prim.get_ast(val_ast)
- return (val_conv, val_conv_ast)
-
- def _to_number(val, val_ast):
- """ Return numbers as they are, and convert everything else to an
- integer. """
- val_conv = val
- val_conv_ast = val_ast
- if not isinstance(val, (float, int, long)):
- conv_prim = Primitive(int)
- if not convert_to_ast:
- val_conv = conv_prim(val)
- else:
- val_conv_ast = conv_prim.get_ast(val_ast)
- return (val_conv, val_conv_ast)
-
- if isinstance(value1, basestring) or isinstance(value2, basestring):
- # convert both to strings
- (value1_conv, value1_conv_ast) = _to_string(value1, value1_ast)
- (value2_conv, value2_conv_ast) = _to_string(value2, value2_ast)
- else:
- # convert both to numbers
- (value1_conv, value1_conv_ast) = _to_number(value1, value1_ast)
- (value2_conv, value2_conv_ast) = _to_number(value2, value2_ast)
-
- if convert_to_ast:
- return (value1_conv_ast, value2_conv_ast)
- else:
- return (value1_conv, value2_conv)
-
- @staticmethod
def plus(arg1, arg2=None):
""" If only one argument is given, prefix it with '+'. If two
arguments are given, add the second to the first. If the first
@@ -768,16 +689,6 @@ class Primitive(object):
return arg1 // arg2
@staticmethod
- def bitwise_and(arg1, arg2):
- """ Return the bitwise AND of the two arguments """
- return arg1 & arg2
-
- @staticmethod
- def bitwise_or(arg1, arg2):
- """ Return the bitwise OR of the two arguments """
- return arg1 | arg2
-
- @staticmethod
def and_(arg1, arg2):
""" Logcially conjoin the two arguments (using short-circuting) """
return arg1 and arg2