Replace is_same_step by __eq__ for Step
This commit is contained in:
parent
7feca92d77
commit
2abee1095a
@ -3,20 +3,6 @@
|
|||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
def is_same_step(new, old):
|
|
||||||
"""Return whether the new step is the same than old step
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
if new.replace(" ", "") == old.replace(" ", ""):
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
except AttributeError:
|
|
||||||
if new == old:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def no_repetition(equals=lambda x,y: x == y):
|
def no_repetition(equals=lambda x,y: x == y):
|
||||||
""" Remove yield values which has already been yield
|
""" Remove yield values which has already been yield
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from .renderable import Renderable
|
|||||||
from .step import Step
|
from .step import Step
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from .generic import transpose_fill
|
from .generic import transpose_fill
|
||||||
from .decorators import is_same_step, no_repetition
|
from .decorators import no_repetition
|
||||||
|
|
||||||
|
|
||||||
class Explicable(Renderable):
|
class Explicable(Renderable):
|
||||||
@ -57,7 +57,7 @@ class Explicable(Renderable):
|
|||||||
""" Generator which yield itself rendered """
|
""" Generator which yield itself rendered """
|
||||||
yield self.STR_RENDER(self.postfix_tokens)
|
yield self.STR_RENDER(self.postfix_tokens)
|
||||||
|
|
||||||
@no_repetition(is_same_step)
|
@no_repetition()
|
||||||
def history_generator(self):
|
def history_generator(self):
|
||||||
r""" Generator for rendered steps which leed to itself
|
r""" Generator for rendered steps which leed to itself
|
||||||
|
|
||||||
|
@ -69,6 +69,14 @@ class Step(Renderable):
|
|||||||
exp
|
exp
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
try:
|
||||||
|
if self.postfix_tokens == other.postfix_tokens:
|
||||||
|
return True
|
||||||
|
except AttributeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Reglages pour 'vim'
|
# Reglages pour 'vim'
|
||||||
|
Loading…
Reference in New Issue
Block a user