Salome HOME
chgt Copyrigth
[tools/eficas.git] / Traducteur / removemocle.py
index d90ad636818b211049698c25fde43564f74708d3..98152fbc2e128cf1d44964332f17ccd3bdea5b93 100644 (file)
@@ -1,12 +1,30 @@
 # -*- coding: utf-8 -*-
+# Copyright (C) 2007-2021   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 regles
-from parseur import FactNode
-from dictErreurs import EcritErreur
-from dictErreurs import jdcSet
+from Traducteur import regles
+from Traducteur.parseur import FactNode
+from Traducteur.dictErreurs import ecritErreur
+from Traducteur.load import jdcSet
 
-#debug=1
 debug=0
+#debug=1
 #on n'a qu'un mocle par commande. On peut donc supprimer le mocle sans trop de précautions (a part iterer a l'envers sur les commandes)
 #avant de supprimer un autre mocle, on remet à jour l'arbre syntaxique (lineno,colno,etc.)
 
@@ -24,7 +42,7 @@ def removeMotCle(jdc,command,mocle,ensemble=regles.SansRegle,erreur = 0):
         for mc in c.childNodes:
             if mc.name != mocle:continue
             if ensemble.verif(c) == 0 : continue
-            if erreur : EcritErreur((command,mocle),c.lineno)
+            if erreur : ecritErreur((command,mocle),c.lineno)
             boolChange=1
             removeMC(jdc,c,mc)
 
@@ -62,11 +80,18 @@ def removeCommande(jdc,command,ensemble=regles.SansRegle,erreur=0):
         if c.name != command:continue
         if ensemble.verif(c) == 0 : continue
         boolChange=1
-        if erreur : EcritErreur((command,),c.lineno)
+        if erreur : ecritErreur((command,),c.lineno)
         jdc.supLignes(c.lineno,c.endline)
         logging.warning("Suppression de %s ligne %s",c.name,c.lineno)
     if boolChange : jdc.reset(jdc.getSource())
 
+#-------------------------------------------------------------
+def removeCommandeSiRegle(jdc,command,liste_regles):
+#-------------------------------------------------------------
+    if command not in jdcSet : return
+    mesRegles=regles.ensembleRegles(liste_regles)
+    removeCommande(jdc,command,mesRegles,0)
+
 #-------------------------------------------------------------
 def removeCommandeSiRegleAvecErreur(jdc,command,liste_regles):
 #-------------------------------------------------------------
@@ -112,7 +137,7 @@ def removeMotCleInFact(jdc,command,fact,mocle,ensemble=regles.SansRegle,erreur=0
                 for n in ll.childNodes:
                     if n.name != mocle:continue
                     if ensemble.verif(c) == 0 : continue
-                    if erreur : EcritErreur((command,fact,mocle),c.lineno)
+                    if erreur : ecritErreur((command,fact,mocle),c.lineno)
                     boolChange=1
                     removeMC(jdc,c,n)
 
@@ -153,7 +178,7 @@ def removeMotCleInFactCourantSiRegle(jdc,command,fact,mocle,liste_regles,erreur=
                 if ensemble.verif(ll) == 0 : continue
                 for n in ll.childNodes:
                     if n.name != mocle:continue
-                    if erreur : EcritErreur((command,fact,mocle),c.lineno)
+                    if erreur : ecritErreur((command,fact,mocle),c.lineno)
                     boolChange=1
                     removeMC(jdc,c,n)
 
@@ -187,5 +212,4 @@ def fusionne(jdc,numLigne):
        fusion=0
  
     if fusion : 
-       import load 
        jdc.joinLineandNext(numLigne)