Salome HOME
reindent + copyright + merge manuel avec la V9_dev sauf repertoires metier
[tools/eficas.git] / Traducteur / movemocle.py
index d75ae999372b7a11aa21594b6959037f77086f87..f4f8fb31fc3594c23483270fd9353098f4e22d35 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2017   EDF R&D
+# 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
@@ -61,7 +61,7 @@ def moveMotCleFromFactToFactMulti(jdc,oper,factsource,mocle,liste_factcible):
 #----------------------------------------------------------------------------
 # exemple type STAT_NON_LINE et RESI_INTER_RELA
     for factcible in liste_factcible :
-       moveMotCleFromFactToFact(jdc,oper,factsource,mocle,factcible)
+        moveMotCleFromFactToFact(jdc,oper,factsource,mocle,factcible)
     removemocle.removeMotCleInFact(jdc,oper,factsource,mocle)
 
 
@@ -77,35 +77,35 @@ def moveMotCleFromFactToFact(jdc,oper,factsource,mocle,factcible):
         if c.name != oper : continue
         cible=None
         for mc in c.childNodes:
-           if mc.name != factcible : 
-              continue
-           else :
-              cible=mc
-              break
+            if mc.name != factcible :
+                continue
+            else :
+                cible=mc
+                break
         if cible==None :
-           if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "cible non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "cible non trouvée"
+            continue
 
         for mc in c.childNodes:
-           source=None
-           if mc.name != factsource:
-              continue
-           else :
-              source=mc
-              break
+            source=None
+            if mc.name != factsource:
+                continue
+            else :
+                source=mc
+                break
         if source==None :
-           if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "source non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", factsource, " ",mocle, "source non trouvée"
+            continue
 
         if debug : print "Changement pour ", oper, " ", factsource, " ",mocle, "cible et source trouvées"
         l=source.childNodes[:]
         for ll in l:
-           for n in ll.childNodes:
-              if n.name != mocle:continue
-              MonTexte=n.getText(jdc);
-              inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte)
-              boolChange=1
-              logging.info("Changement de place   %s ligne %s vers %s",n.name, n.lineno, cible.name)
+            for n in ll.childNodes:
+                if n.name != mocle:continue
+                MonTexte=n.getText(jdc);
+                inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte)
+                boolChange=1
+                logging.info("Changement de place   %s ligne %s vers %s",n.name, n.lineno, cible.name)
     if boolChange : jdc.reset(jdc.getSource())
     removemocle.removeMotCleInFact(jdc,oper,factsource,mocle)
 
@@ -126,25 +126,25 @@ def moveMotClefInOperToFact(jdc,oper,mocle,factcible,plusieursFois=True):
         if c.name != oper : continue
         cible=None
         for mc in c.childNodes:
-           if mc.name != factcible : 
-              continue
-           else :
-              cible=mc
-              break
+            if mc.name != factcible :
+                continue
+            else :
+                cible=mc
+                break
         if cible==None :
-           if debug : print "Pas de changement pour ", oper, " ", factcible, " ", "cible non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", factcible, " ", "cible non trouvée"
+            continue
 
         source=None
         for mc in c.childNodes:
-           if mc.name != mocle:
-              continue
-           else :
-              source=mc
-              break
+            if mc.name != mocle:
+                continue
+            else :
+                source=mc
+                break
         if source==None :
-           if debug : print "Pas de changement pour ", oper, " ", mocle, " source non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", mocle, " source non trouvée"
+            continue
         MonTexte=source.getText(jdc);
         boolChange=1
         inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte,plusieursFois)
@@ -164,51 +164,51 @@ def copyMotClefInOperToFact(jdc,oper,mocle,factcible):
         if c.name != oper : continue
         cible=None
         for mc in c.childNodes:
-           if mc.name != factcible : 
-              continue
-           else :
-              cible=mc
-              break
+            if mc.name != factcible :
+                continue
+            else :
+                cible=mc
+                break
         if cible==None :
-           if debug : print "Pas de changement pour ", oper, " ", factcible, " ", "cible non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", factcible, " ", "cible non trouvée"
+            continue
 
         source=None
         for mc in c.childNodes:
-           if mc.name != mocle:
-              continue
-           else :
-              source=mc
-              break
+            if mc.name != mocle:
+                continue
+            else :
+                source=mc
+                break
         if source==None :
-           if debug : print "Pas de changement pour ", oper, " ", mocle, " source non trouvée"
-           continue
+            if debug : print "Pas de changement pour ", oper, " ", mocle, " source non trouvée"
+            continue
         MonTexte=source.getText(jdc);
         boolChange=1
         inseremocle.insereMotCleDansFacteur(jdc,cible,MonTexte)
     if boolChange : jdc.reset(jdc.getSource())
-    
+
 #----------------------------------------------------------------------
 def moveMCFToCommand(jdc,command,factsource,commandcible,factcible):
 #----------------------------------------------------------------------
 # exemple CONTACT en 10
-# CONTACT devient commande DEFI_CONTACT/ZONE 
-# 
+# CONTACT devient commande DEFI_CONTACT/ZONE
+#
     if command not in jdcSet : return
     boolChange=0
     commands= jdc.root.childNodes[:]
     commands.reverse()
     for c in commands:
-       if c.name != command  : continue
-       for mcF in c.childNodes:
-           if mcF.name != factsource : continue
-           l=mcF.getText(jdc)
-           texte=l.replace(factsource,factcible)
-           texte='xxxx='+commandcible+'('+texte+')\n'
-           jdc.splitLine(c.lineno,0)
-           jdc.addLine(texte,c.lineno)
-           logging.info("Deplacement de %s dans %s ligne %s",factsource,commandcible,c.lineno)
-           boolChange=1
+        if c.name != command  : continue
+        for mcF in c.childNodes:
+            if mcF.name != factsource : continue
+            l=mcF.getText(jdc)
+            texte=l.replace(factsource,factcible)
+            texte='xxxx='+commandcible+'('+texte+')\n'
+            jdc.splitLine(c.lineno,0)
+            jdc.addLine(texte,c.lineno)
+            logging.info("Deplacement de %s dans %s ligne %s",factsource,commandcible,c.lineno)
+            boolChange=1
     if boolChange :
         jdc.reset(jdc.getSource())
         jdcSet.add(commandcible)
@@ -221,26 +221,26 @@ def fusionMotCleToFact(jdc,command,listeMc,factcible,defaut=0):
     commands= jdc.root.childNodes[:]
     commands.reverse()
     for c in commands:
-       if c.name != command  : continue
-       list_val=[]
-       trouveUnMC=0
-       for mc in c.childNodes:
-           if mc.name not in listeMc : continue
-           val=mc.getText(jdc).split("=")[1].split(",")[0]
-           list_val.append(val)
-           trouveUnMC=1
-       if trouveUnMC :
-           TexteMC=factcible+"=("
-           for val in list_val : TexteMC=TexteMC+val+","
-           TexteMC=TexteMC[:-1]+"),"
-           inseremocle.insereMotCle(jdc,c,TexteMC)
-           jdc.reset(jdc.getSource())
-           boolChange=1
+        if c.name != command  : continue
+        list_val=[]
+        trouveUnMC=0
+        for mc in c.childNodes:
+            if mc.name not in listeMc : continue
+            val=mc.getText(jdc).split("=")[1].split(",")[0]
+            list_val.append(val)
+            trouveUnMC=1
+        if trouveUnMC :
+            TexteMC=factcible+"=("
+            for val in list_val : TexteMC=TexteMC+val+","
+            TexteMC=TexteMC[:-1]+"),"
+            inseremocle.insereMotCle(jdc,c,TexteMC)
+            jdc.reset(jdc.getSource())
+            boolChange=1
     if boolChange :
         jdc.reset(jdc.getSource())
-        for mc in listeMc : 
-           removemocle.removeMotCle(jdc,command,mc)
-           jdc.reset(jdc.getSource())
+        for mc in listeMc :
+            removemocle.removeMotCle(jdc,command,mc)
+            jdc.reset(jdc.getSource())
 
 #-----------------------------------------------------
 def fusionMotCleInFact(jdc,command,fact,listeMc,new_name,defaut=0):
@@ -268,9 +268,9 @@ def fusionMotCleInFact(jdc,command,fact,listeMc,new_name,defaut=0):
                     boolChange=1
     if boolChange :
         jdc.reset(jdc.getSource())
-        for mc in listeMc : 
-           removemocle.removeMotCleInFact(jdc,command,fact,mc)
-           jdc.reset(jdc.getSource())
+        for mc in listeMc :
+            removemocle.removeMotCleInFact(jdc,command,fact,mc)
+            jdc.reset(jdc.getSource())
 
 #-----------------------------------------------------
 def fusionMCFToMCF(jdc,command,listeMcF,factcible,defaut=0):
@@ -312,7 +312,7 @@ def fusionMCFToMCF(jdc,command,listeMcF,factcible,defaut=0):
             boolChange=1
     if boolChange :
         jdc.reset(jdc.getSource())
-        for mcF in listeMcF : 
+        for mcF in listeMcF :
             removemocle.removeMotCle(jdc,command,mcF)
             jdc.reset(jdc.getSource())
 
@@ -326,21 +326,21 @@ def eclaMotCleToFact(jdc,command,motcle,mot1,mot2,defaut=0):
     if command  not in jdcSet : return
     boolChange=0
     for c in jdc.root.childNodes:
-       if c.name != command  : continue
-       trouveUnMC=0
-       for mc in c.childNodes:
-           if mc.name != motcle : continue
-           trouveUnMC=1
-           TexteMC=mc.getText(jdc)
-           indexLigneGlob=mc.lineno-1
-           MaLigneGlob=jdc.getLines()[indexLigneGlob]
-           Ligne=TexteMC.split('(')[1].split(')')[0].split(',')
-           motcle1=mot1+"="+Ligne[0]
-           motcle2=mot2+"=("+Ligne[1]+','+Ligne[2]+','+Ligne[3]+')'
-           texte=motcle+'=_F('+motcle1+','+motcle2+')'
-           num=lastParen(TexteMC)
-           Nouveau=MaLigneGlob.replace(TexteMC[0:num],texte)
-           jdc.getLines()[indexLigneGlob]=Nouveau
-           logging.info("Transformation de %s dans %s ligne %s",motcle,command,c.lineno)
-           boolChange=1
+        if c.name != command  : continue
+        trouveUnMC=0
+        for mc in c.childNodes:
+            if mc.name != motcle : continue
+            trouveUnMC=1
+            TexteMC=mc.getText(jdc)
+            indexLigneGlob=mc.lineno-1
+            MaLigneGlob=jdc.getLines()[indexLigneGlob]
+            Ligne=TexteMC.split('(')[1].split(')')[0].split(',')
+            motcle1=mot1+"="+Ligne[0]
+            motcle2=mot2+"=("+Ligne[1]+','+Ligne[2]+','+Ligne[3]+')'
+            texte=motcle+'=_F('+motcle1+','+motcle2+')'
+            num=lastParen(TexteMC)
+            Nouveau=MaLigneGlob.replace(TexteMC[0:num],texte)
+            jdc.getLines()[indexLigneGlob]=Nouveau
+            logging.info("Transformation de %s dans %s ligne %s",motcle,command,c.lineno)
+            boolChange=1
     if boolChange : jdc.reset(jdc.getSource())