X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Traducteur%2Frenamemocle.py;h=1b6294d90370b9fd5e79b0457068c372be900fa1;hb=9f4ff7ed9afd87c96e11d61e442e39e5511f60d1;hp=90c0aa35e2f4533a7f5a00b99b2a75ca8a8b0930;hpb=d41b1c52d0c35b655f6feabfe816a3c541f3a92a;p=tools%2Feficas.git diff --git a/Traducteur/renamemocle.py b/Traducteur/renamemocle.py index 90c0aa35..1b6294d9 100644 --- a/Traducteur/renamemocle.py +++ b/Traducteur/renamemocle.py @@ -1,10 +1,28 @@ # -*- 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 @@ -111,6 +129,33 @@ def renameMotCleInFactSiRegle(jdc,command,fact,mocle,new_name,liste_regles): 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): #-----------------------------------------------------------------