Commit 09820ea8 authored by Taddeus Kroes's avatar Taddeus Kroes

Added the possibility to use a function to create a hint message.

parent 6a78440d
...@@ -16,7 +16,12 @@ class Possibility(object): ...@@ -16,7 +16,12 @@ class Possibility(object):
def __str__(self): def __str__(self):
if self.handler in MESSAGES: if self.handler in MESSAGES:
return MESSAGES[self.handler].format(self.root, *self.args) msg = MESSAGES[self.handler]
if callable(msg):
msg = msg(self.root, self.args)
return msg.format(self.root, *self.args)
return repr(self) return repr(self)
......
...@@ -98,7 +98,16 @@ def subtract_term(root, args): ...@@ -98,7 +98,16 @@ def subtract_term(root, args):
return eq(left - term, right - term) return eq(left - term, right - term)
MESSAGES[subtract_term] = _('Subtract {1} from both sides of the equation.') def subtract_term_msg(root, args):
term = args[0]
if term.negated == 1:
return _('Add %s to both sides of the equation.' % +term)
return _('Subtract {1} from both sides of the equation.')
MESSAGES[subtract_term] = subtract_term_msg
def divide_term(root, args): def divide_term(root, args):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment