Allow to use Greater/Less PYSON with Decimal
This commit is contained in:
1 parent
a1d4e5af1a
commit
82bc90b8ff
1 file changed
+10
@@ -279,8 +279,17 @@ class Greater(PYSON):
|
||||
def types(self):
|
||||
return set([bool])
|
||||
|
||||
@staticmethod
|
||||
def _convert(dct):
|
||||
for i in ('s1', 's2'):
|
||||
if not isinstance(dct[i], (int, long, float)):
|
||||
dct = dct.copy()
|
||||
dct[i] = float(dct[i])
|
||||
return dct
|
||||
|
||||
@staticmethod
|
||||
def eval(dct, context):
|
||||
dct = Greater._convert(dct)
|
||||
if dct['e']:
|
||||
return dct['s1'] >= dct['s2']
|
||||
else:
|
||||
@@ -296,6 +305,7 @@ class Less(Greater):
|
||||
|
||||
@staticmethod
|
||||
def eval(dct, context):
|
||||
dct = Less._convert(dct)
|
||||
if dct['e']:
|
||||
return dct['s1'] <= dct['s2']
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user