-#@ MODIF interpreteur_formule Accas DATE 02/07/2001 AUTEUR D6BHHJP J.P.LEFEBVRE
-# CONFIGURATION MANAGEMENT OF EDF VERSION
-# ======================================================================
-# COPYRIGHT (C) 1991 - 2001 EDF R&D WWW.CODE-ASTER.ORG
-# SEE THE FILE "LICENSE.TERMS" FOR INFORMATION ON USAGE AND
-# REDISTRIBUTION OF THIS FILE.
-# ======================================================================
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2013 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
import string,re,sys,exceptions,types
from Noyau.N_CR import CR
+from Extensions.i18n import tr
+
def group(*choices): return '(' + string.join(choices, '|') + ')'
def any(*choices): return apply(group, choices) + '*'
Méthode externe
"""
if type(formule) != types.TupleType:
- raise InterpreteurException,"La formule passée à l'interpréteur doit être sous forme de tuple"
+ raise InterpreteurException,tr("La formule passee à l'interpreteur doit etre sous forme de tuple")
self.t_formule = formule
self.init_cr()
self.modify_listes()
nom = self.t_formule[0]
if nom :
if nom[0] in ('+','-') : nom = nom[1:]
- self.cr.debut = "Début Fonction %s" %nom
- self.cr.fin = "Fin Fonction %s" %nom
+ self.cr.debut = tr("Debut Fonction %s", nom)
+ self.cr.fin = tr("Fin Fonction %s", nom)
def str(self):
"""
"""
Réalise l'interprétation du corps de la formule
"""
- texte = self.t_formule[3]\r
+ texte = self.t_formule[3]
if not texte : return
if type(texte) != types.ListType:
texte = [texte,]
try:
self.l_operateurs.append(self.split_operateurs(text_arg))
except InterpreteurException,e:
- self.cr.fatal(str(e))
+ self.cr.fatal(e.__str__())
def modify_listes(self):
"""
try:
oper,reste = self.cherche_nombre(texte)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not oper :
# on recherche une constante en début de texte
try:
oper,reste = self.cherche_constante(texte)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not oper :
# on recherche une expression entre parenthèses...
try:
oper,reste = self.cherche_expression_entre_parentheses(texte)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not oper :
# on recherche le début d'un opérateur unaire en début de texte
try:
oper,reste = self.cherche_operateur_unaire(texte)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not oper :
type_objet,nom_objet = self.get_type(texte)
if type_objet == 'constante':
try:
l_op = self.split_operateurs(reste)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
l_operateurs.extend(l_op)
return l_operateurs
else:
try:
args,reste = self.cherche_args(texte)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not args :
# opérateur unaire sans arguments
raise InterpreteurException,'opérateur unaire %s sans arguments' %operateur
try:
args,reste = self.cherche_args(reste)
except InterpreteurException,e:
- raise InterpreteurException,str(e)
+ raise InterpreteurException,e.__str__()
if not args :
# opérateur unaire sans arguments
# en principe on ne doit jamais être dans ce cas car il est déjà trappé par cherche_constante ...
texte = reste
return operateur,reste
elif texte[0] == '-':
- # Il faut pouvoir trapper les expressions du type exp(-(x+1)) ...
- try :
- args,reste = self.cherche_args(texte[1:])
- except InterpreteurException,e:
- raise InterpreteurException,str(e)
- if not args :
- # Il ne s'agit pas de '-' comme opérateur unaire --> on retourne None
- return None,texte
- else:
- identificateur = '-'
- args = self.split_args(identificateur,args,self.d_fonctions_unaires[identificateur])
+ # Il faut pouvoir trapper les expressions du type exp(-(x+1)) ...
+ try :
+ args,reste = self.cherche_args(texte[1:])
+ except InterpreteurException,e:
+ raise InterpreteurException,e.__str__()
+ if not args :
+ # Il ne s'agit pas de '-' comme opérateur unaire --> on retourne None
+ return None,texte
+ else:
+ identificateur = '-'
+ args = self.split_args(identificateur,args,self.d_fonctions_unaires[identificateur])
formule_operateur = (identificateur,'',self.t_formule[2],args)
operateur = Interpreteur_Formule(formule = formule_operateur,
constantes = self.new_constantes,