Commit 53b7feba authored by Jérôme Ortais's avatar Jérôme Ortais
Browse files

Correction d'un bug introduit dans...

Correction d'un bug introduit dans https://github.com/Pyromaths/pyromaths/commit/bdad116cf361229a9f0de83d81788d4b893ac7d0
pour corriger l'issue  https://github.com/Pyromaths/pyromaths/issues/18.
Ajout du chemin courant à pyromaths.cli.__main__ afin qu'il n'utilise
pas la version installée de Pyromaths.
parent 0cee4788
......@@ -33,6 +33,13 @@ import sys
# Quick and dirty definition of `_` as the identity function
gettext.install('pyromaths', unicode=1)
from os.path import dirname, realpath, split, join
from os import pardir
basedir = dirname(realpath(__file__))
_path, _dir = split(basedir)
sys.path[0] = realpath(join(_path, pardir))
exec ("from pyromaths import pyromaths")
from pyromaths.cli import exercise_argument, PyromathsException
from pyromaths.ex.test import TestPerformer, generate
......
......@@ -274,13 +274,16 @@ def splitting(calcul):
['-6', '*', '(-11)', '*', '(-5)']
>>> Priorites3.splitting("Fraction(1,7)x^2-Fraction(3,8)x-1")
['Fraction(1,7)', 'x', '^', '2', '-', 'Fraction(3,8)', 'x', '-', '1']
>>> splitting('-7**2')
['-', '7', '**', '2']
:rtype: list
"""
if calcul == "": return []
l = split_calcul(calcul)
if l[0] == "+" and len(l) > 1: l[0] += l.pop(1)
elif l[0] == "-" and len(l) > 1 and l[1][0] in "0123456789": l[0] += l.pop(1)
elif l[0] == "-" and len(l) > 1 and l[1][0] in "0123456789":
if len(l)==2 or (len(l)>2 and l[2]!="**" and l[2]!="^"): l[0] += l.pop(1)
j = 0
while j < len(l):
op, i, t = l[j], 0, []
......@@ -694,8 +697,8 @@ def priorites(calcul):
:rtype: list
"""
#calcul = splitting(calcul)
calcul = split_calcul(calcul)
calcul = splitting(calcul)
#calcul = split_calcul(calcul)
solution = []
while len(calcul) > 1:
s = effectue_calcul(calcul)
......
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