# -*- 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 logging
import sys
-from parseur import FactNode
-from dictErreurs import jdcSet
-import regles
-from dictErreurs import EcritErreur
+from Traducteur.parseur import FactNode
+from Traducteur.load import jdcSet
+from Traducteur import regles
+from Traducteur.dictErreurs import EcritErreur
#debug=1
debug=0
mesRegles=regles.ensembleRegles(liste_regles)
renameMotCleInFact(jdc,command,fact,mocle,new_name,mesRegles)
+def renameMotCleInFactCourantSiRegle(jdc,command,fact,mocle,new_name,liste_regles,erreur=0):
+#--------------------------------------------------------------------------
+ if command not in jdcSet : return
+ ensemble=regles.ensembleRegles(liste_regles)
+ boolChange=0
+ for c in jdc.root.childNodes:
+ if c.name != command:continue
+ for mc in c.childNodes:
+ if mc.name != fact:continue
+ l=mc.childNodes[:]
+ #on itere a l'envers
+ l.reverse()
+ for ll in l:
+ if ensemble.verif(ll) == 0 : continue
+ for n in ll.childNodes:
+ if n.name != mocle:continue
+ s=jdc.getLines()[n.lineno-1]
+ jdc.getLines()[n.lineno-1]=s[:n.colno]+new_name+s[n.colno+len(mocle):]
+ boolChange=1
+ if erreur :
+ EcritErreur((command,fact,mocle),c.lineno)
+ else :
+ logging.info("Renommage de: %s, ligne %s, en %s",n.name,n.lineno,new_name)
+
+ if boolChange : jdc.reset(jdc.getSource())
+
+
#-----------------------------------------------------------------
def renameCommande(jdc,command,new_name,ensemble=regles.SansRegle):
#-----------------------------------------------------------------