develop_steps become classmethod
This commit is contained in:
parent
142eaa9c32
commit
20d1ad8528
@ -243,14 +243,15 @@ class Expression(Explicable):
|
|||||||
tmpTokenList += tokenList
|
tmpTokenList += tokenList
|
||||||
self.child = Expression(tmpTokenList)
|
self.child = Expression(tmpTokenList)
|
||||||
|
|
||||||
steps = self.develop_steps(tmpTokenList)
|
steps = Expression.develop_steps(tmpTokenList)
|
||||||
|
|
||||||
if self.child.postfix_tokens == ini_step.postfix_tokens:
|
if self.child.postfix_tokens == ini_step.postfix_tokens:
|
||||||
self.child.steps = steps
|
self.child.steps = steps
|
||||||
else:
|
else:
|
||||||
self.child.this_append_before([ini_step] + steps)
|
self.child.this_append_before([ini_step] + steps)
|
||||||
|
|
||||||
def develop_steps(self, tokenList):
|
@classmethod
|
||||||
|
def develop_steps(cls, tokenList):
|
||||||
""" From a list of tokens, it develops steps of each tokens """
|
""" From a list of tokens, it develops steps of each tokens """
|
||||||
tmp_steps = []
|
tmp_steps = []
|
||||||
for t in tokenList:
|
for t in tokenList:
|
||||||
@ -264,18 +265,15 @@ class Expression(Explicable):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
tmp_steps.append([t])
|
tmp_steps.append([t])
|
||||||
|
|
||||||
if max([len(i) for i in tmp_steps]) == 1:
|
if max([len(i) for i in tmp_steps]) > 1:
|
||||||
# Cas où rien n'a dû être expliqué.
|
|
||||||
return []
|
|
||||||
elif min([len(i) for i in tmp_steps]) == 0:
|
|
||||||
raise ValueError('tmp_steps: {} \ntokenList: {}'.format(tmp_steps, tokenList))
|
|
||||||
else:
|
|
||||||
tmp_steps = expand_list(tmp_steps)[:-1]
|
tmp_steps = expand_list(tmp_steps)[:-1]
|
||||||
steps = [Expression(s) for s in tmp_steps]
|
steps = [Expression(s) for s in tmp_steps]
|
||||||
return steps
|
return steps
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def isExpression(self, other):
|
def isExpression(cls, other):
|
||||||
try:
|
try:
|
||||||
other._isExpression
|
other._isExpression
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user