import logging
from parseur import FactNode
from dictErreurs import jdcSet
+from dictErreurs import EcritErreur
import string
import regles
debug=0
nbBlanc=node1.colno
return " "*nbBlanc
-#------------------------------------------------------------------------------
-def chercheOperInsereFacteur(jdc,nomcommande,nouveau,ensemble=regles.SansRegle):
-#------------------------------------------------------------------------------
+#---------------------------------------------------------------------------------------------------------
+def chercheOperInsereFacteur(jdc,nomcommande,nouveau,ensemble=regles.SansRegle, estunFacteur=1, erreur=0):
+#--------------------------------------------------------------------------------------------------------
# Cherche l oper
# cree le texte
# appelle insereMotCle pour ajouter le texte
#
boolChange=0
- texte=nouveau+"=_F(),"
+ if estunFacteur :
+ texte=nouveau+"=_F(),"
+ else :
+ texte=nouveau
if nomcommande not in jdcSet : return
commands= jdc.root.childNodes[:]
commands.reverse()
for c in commands:
if c.name != nomcommande:continue
if ensemble.verif(c) == 0 : continue
+ if erreur : EcritErreur((nomcommande,nouveau),c.lineno)
boolChange=1
insereMotCle(jdc,c,texte)
if boolChange : jdc.reset(jdc.getSource())
-#------------------------------------------------------------------------
-def chercheOperInsereFacteurSiRegle(jdc,nomcommande,nouveau,liste_regles):
-#------------------------------------------------------------------------
+#----------------------------------------------------------------------------------------
+def chercheOperInsereFacteurSiRegle(jdc,nomcommande,nouveau,liste_regles, estunFacteur=1):
+#----------------------------------------------------------------------------------------
# Cherche l oper
# cree le texte
# appelle insereMotCle pour ajouter le texte
#
if nomcommande not in jdcSet : return
mesRegles=regles.ensembleRegles(liste_regles)
- chercheOperInsereFacteur(jdc,nomcommande,nouveau,mesRegles)
+ chercheOperInsereFacteur(jdc,nomcommande,nouveau,mesRegles,estunFacteur)
+#---------------------------------------------------------------------------------------------------------
+def chercheOperInsereFacteurSiRegleAvecAvertissement(jdc,nomcommande,nouveau,liste_regles, estunFacteur=1):
+#---------------------------------------------------------------------------------------------------------
+ if nomcommande not in jdcSet : return
+ mesRegles=regles.ensembleRegles(liste_regles)
+ chercheOperInsereFacteur(jdc,nomcommande,nouveau,mesRegles,estunFacteur,erreur=1)
#-------------------------------------------------------------------------------------------------
def AjouteMotClefDansFacteur(jdc,commande,fact,nouveau,ensemble=regles.SansRegle, estunFacteur=0):
jdc.getLines()[ligne] = s[-1*nbBlanc:]
ligne=ligne+1
-#----------------------------------------------------------
-def renameMotCleInFact(jdc,command,fact,mocle,new_name):
-#----------------------------------------------------------
+#----------------------------------------------------------------------------------
+def renameMotCleInFact(jdc,command,fact,mocle,new_name, ensemble=regles.SansRegle):
+#----------------------------------------------------------------------------------
if command not in jdcSet : return
boolChange=0
for c in jdc.root.childNodes:
for ll in l:
for n in ll.childNodes:
if n.name != mocle:continue
+ if ensemble.verif(c) == 0 : 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 boolChange : jdc.reset(jdc.getSource())
+#--------------------------------------------------------------------------
+def renameMotCleInFactSiRegle(jdc,command,fact,mocle,new_name,liste_regles):
+#--------------------------------------------------------------------------
+ if command not in jdcSet : return
+ mesRegles=regles.ensembleRegles(liste_regles)
+ renameMotCleInFact(jdc,command,fact,mocle,new_name,mesRegles)
+
#-----------------------------------------------------------------
def renameCommande(jdc,command,new_name,ensemble=regles.SansRegle):
#-----------------------------------------------------------------
if ensemble.verif(c) == 0 : continue
boolChange=1
if debug:print "Renommage de:",c.name,new_name ,c.lineno,c.colno
- logging.info("Renommage de: %s, %s, %s, %s en %s",c.name,"",c.lineno,c.colno,new_name)
+ logging.info("Renommage de: %s en ligne %d en %s",c.name,c.lineno,new_name)
s=jdc.getLines()[c.lineno-1]
jdc.getLines()[c.lineno-1]=s[:c.colno]+new_name+s[c.colno+len(command):]
"DEFI_THER_JOULE","DYNA_TRAN_EXPLI","DEBUT","CALC_CHAM_ELEM",
"AFFE_CHAR_THER", "MACR_LIGN_COUPE","POST_RCCM","PROJ_MESU_MODAL",
"CREA_RESU","DIST_LIGN_3D","MODI_MAILLAGE","LIRE_TABLE",
- "POST_SIMPLIFIE","AFFE_MATERIAU"
+ "POST_SIMPLIFIE","AFFE_MATERIAU","DEFI_MAILLAGE","DEPL_INTERNE","CREA_CHAMP"
)
#atraiter=( "IMPR_GENE",)
dStatNonLine={"ELAS":"ELAS_THER"}
lavertit=("ELAS")
- ChangementValeurDsMCFAvecAvertissement(jdc,"STAT_NON_LINE","COMP-INCR","RELATION_KIT",dStatNonLine,lavertit)
+ ChangementValeurDsMCFAvecAvertissement(jdc,"STAT_NON_LINE","COMP_INCR","RELATION_KIT",dStatNonLine,lavertit)
- lavertit=("CHABOCHE","ASSE_COMBU")
- dchaboche={"CHABOCHE":"VMIS_CIN1_CHAB","ASSE_COMBU":"XXX_IRA"}
+ lavertit=("CHABOCHE","ASSE_COMBU","OHNO")
+ dchaboche={"CHABOCHE":"VMIS_CIN1_CHAB","ASSE_COMBU":"XXX_IRA","OHNO":"VISC_TAHERI"}
ChangementValeurDsMCFAvecAvertissement(jdc,"STAT_NON_LINE","COMP_INCR","RELATION",dchaboche,lavertit)
####################### traitement DEFI_MATERIAU #######################
moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","L",("LEMAITRE_IRRA",))
removeMotCle(jdc,"DEFI_MATERIAU","FLU_IRRA")
renameMotCleAvecErreur(jdc,"DEFI_MATERIAU","CHABOCHE","CINx_CHAB")
+ renameMotCleAvecErreur(jdc,"DEFI_MATERIAU","OHNO","VISC_TAHERI")
+ renameMotCleAvecErreur(jdc,"DEFI_MATERIAU","OHNO_FO","VISC_TAHERI_FO")
####################### traitement DEFI_MATERIAU #######################
renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","A","GRAN_A")
moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_S",("LEMAITRE_IRRA",))
removeMotCle(jdc,"DEFI_MATERIAU","GRAN_IRRA")
- ####################### traitement DEFI_MATERIAU #######################
chercheOperInsereFacteurSiRegle(jdc,"DEFI_MATERIAU","ELAS",((("CABLE",),"existe"),))
moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","CABLE","E", ("ELAS",))
moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","CABLE","NU", ("ELAS",))
removeMotCle(jdc,"AFFE_CHAR_THER_F","VERI_DDL")
removeMotCle(jdc,"AFFE_CHAR_THER","VERI_DDL")
+ ####################### traitement CALC_G #######################
chercheOperInsereFacteurSiRegle(jdc,"CALC_G_LOCAL_T","LISSAGE",((("LISSAGE_G","LISSAGE_THETA","DEGRE"),"existeMCFParmi"),))
moveMotClefInOperToFact(jdc,"CALC_G_LOCAL_T","LISSAGE_THETA","LISSAGE")
moveMotClefInOperToFact(jdc,"CALC_G_LOCAL_T","LISSAGE_G","LISSAGE")
moveMotClefInOperToFact(jdc,"CALC_G_LOCAL_T","DEGRE","LISSAGE")
- ####################### traitement CALC_G #######################
dlocal={"CALC_G_LGLO":"G_LAGR", "G_BILINEAIRE":"G_BILI", "CALC_G_MAX":"G_MAX"}
ChangementValeur(jdc,"CALC_G_LOCAL_T","OPTION",dlocal)
#
moveMotClefInOperToFact(jdc,"CALC_G","R_INF","THETA")
moveMotClefInOperToFact(jdc,"CALC_G","R_SUP","THETA")
moveMotClefInOperToFact(jdc,"CALC_G","FISSURE","THETA")
+ renameMotCleInFactSiRegle(jdc,"CALC_G","THETA","THETA","THETA_LAGR",((("THETA","R_INF"),"existeMCsousMCF"),))
+ renameMotCleInFactSiRegle(jdc,"CALC_G","THETA","THETA","THETA_LAGR",((("THETA","R_SUP"),"existeMCsousMCF"),))
+ moveMotCleFromFactToFather(jdc,"CALC_G","THETA","THETA_LAGR")
+ removeMotCleAvecErreur(jdc,"CALC_G","MODELE")
+ removeMotCleAvecErreur(jdc,"CALC_G","DEPL")
+ removeMotCleAvecErreur(jdc,"CALC_G","CHAM_MATER")
+ removeMotCleAvecErreur(jdc,"CALC_G","CARA_ELEM")
+ chercheOperInsereFacteurSiRegleAvecAvertissement(jdc,"CALC_G","RESULTAT=XXX,",((("THETA_LAGR",),"existeMCFParmi"),),0)
####################### traitement AFFE_MODELE #######################
daffeModele={"PLAN_FISSURE":"PLAN_JOINT", "AXIS_FISSURE":"AXIS_JOINT","OHNO_FO":"VISC_TAHERI_FO","OHNO":"VISC_TAHERI"}
lavertit=("OHNO","OHNO_FO")
ChangementValeurDsMCFAvecAvertissement(jdc,"AFFE_MODELE","AFFE","MODELISATION",daffeModele,lavertit)
removeMotCleSiRegleAvecErreur(jdc,"AFFE_MODELE","AFFE",((("AFFE","MODELISATION","APPUI_REP",jdc),"MCsousMCFaPourValeur"),))
+ renameMotCleInFact(jdc,"AFFE_MODELE","AFFE_SOUS_STRUC","MAILLE","SUPER_MAILLE")
####################### traitement PROJ_MESU_MODAL #######################
removeMotCleInFact(jdc,"PROJ_MESU_MODAL","MODELE_MESURE","NOM_PARA")
####################### traitement AFFE_MATERIAU #######################
removeMotCleInFact(jdc,"AFFE_MATERIAU","AFFE","SECH_REF")
+ ####################### traitement DEFI_MAILLAGE #######################
+ renameMotCleInFact(jdc,"DEFI_MAILLAGE","DEFI_MAILLE","MAILLE","SUPER_MAILLE")
+ renameMotCle(jdc,"DEFI_MAILLAGE","DEFI_MAILLE","DEFI_SUPER_MAILLE")
+ renameMotCleInFact(jdc,"DEFI_MAILLAGE","RECO_GLOBAL","MAILLE","SUPER_MAILLE")
+ renameMotCleInFact(jdc,"DEFI_MAILLAGE","RECO_MAILLE","MAILLE","SUPER_MAILLE")
+ renameMotCle(jdc,"DEFI_MAILLAGE","RECO_MAILLE","RECO_SUPER_MAILLE")
+ renameMotCleInFact(jdc,"DEFI_MAILLAGE","DEFI_NOEUD","MAILLE","SUPER_MAILLE")
+ renameMotCleInFact(jdc,"DEFI_MAILLAGE","DEFI_GROUP_NO","MAILLE","SUPER_MAILLE")
+
+ ####################### traitement DEPL_INTERNE #######################
+ renameMotCle(jdc,"DEPL_INTERNE","MAILLE","SUPER_MAILLE")
+
+ ####################### traitement CREA_CHAMP #######################
+ chercheOperInsereFacteurSiRegle(jdc,"CREA_CHAMP","TYPE_MAXI='MAXI',",((("TYPE_RESU"),"existeMCFParmi"),),estunFacteur=0)
+# chercheOperInsereFacteur(jdc,"CREA_CHAMP","TYPE_MAXI='MAXI',",estunFacteur=0)
+
f=open(outfile,'w')
f.write(jdc.getSource())
f.close()
- #hdlr.close()
- #logging.shutdown()
log.ferme(hdlr)
def main():