From: Pascale Noyret Date: Thu, 23 Nov 2006 18:32:05 +0000 (+0000) Subject: PN pour partage avec CC X-Git-Tag: V1_11b3~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e5827665f26735efddbc5d301618f10bfdbbc73;p=modules%2Feficas.git PN pour partage avec CC --- diff --git a/Traducteur/log.py b/Traducteur/log.py index ca1226c3..3e440867 100644 --- a/Traducteur/log.py +++ b/Traducteur/log.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- import logging +logger=logging.getLogger() def initialise() : - logger=logging.getLogger() hdlr=logging.FileHandler('/tmp/convert.log','w') formatter = logging.Formatter('%(levelname)s: %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.INFO) return hdlr + + +def ferme (hdlr) : + logger.removeHandler(hdlr) diff --git a/Traducteur/traduitV7V8.py b/Traducteur/traduitV7V8.py new file mode 100644 index 00000000..bca9cb54 --- /dev/null +++ b/Traducteur/traduitV7V8.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +""" +usage="""usage: %prog [options] +Typical use is: + python traduitV7V8.py --infile=xxxx --outfile=yyyy +""" + +import log +import optparse + +from load import getJDC +from mocles import parseKeywords +from removemocle import * +from renamemocle import * +from renamemocle import * +from inseremocle import * +from changeValeur import * +from movemocle import * +from dictErreurs import GenereErreurPourCommande + +# Demander a emmanuel pour affe_char_ther et test_resu +import calcG + +atraiter=( "IMPR_GENE","CALC_FONCTION", "DEFI_MATERIAU","STAT_NON_LINE", + "CALC_G_LOCAL_T","CALC_G_THETA_T","CALC_G","AFFE_CHAR_MECA", + "AFFE_CHAR_THER_F","IMPR_CO","DEFI_SQUELETTE","DEFI_FONCTION", + "CALC_THETA","AFFE_MODELE","DYNA_NON_LINE","CALC_ELEM", + "CALC_NO","EXTR_MODE","CALC_META","IMPR_RESU","TEST_RESU", + "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" + ) + +#atraiter=( "IMPR_GENE",) + +def traduc(infile,outfile): + + hdlr=log.initialise() + jdc=getJDC(infile,atraiter) + root=jdc.root + + #Parse les mocles des commandes + parseKeywords(root) + + ####################### traitement erreurs ####################### + GenereErreurPourCommande(jdc,("POST_RCCM","DIST_LIGN_3D")) + + ####################### traitement CALC_META ####################### + renameMotCleInFact(jdc,"CALC_META","ETAT_INIT","META_INIT","META_INIT_ELNO") + + ####################### traitement CALC_FONCTION ####################### + removeMotCleSiRegle(jdc,"CALC_FONCTION","NOM_PARA",((("MAX"),"existeMCFParmi"),)) + renameCommandeSiRegle(jdc,"CALC_FONCTION","INFO_FONCTION", ((("RMS","MAX","NOCI_SEISME","NORME","ECART-TYPE"),"existeMCFParmi"),)) + + ####################### traitement IMPR_GENE ####################### + moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","UNITE") + moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","FORMAT") + + ####################### traitement STAT/DYNA_NON_LINE ####################### + moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","RESI_INTE_RELA",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","ITER_INTE_MAXI",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","ITER_INTE_PAS",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","RESO_INTE",("COMP_INCR","COMP_ELAS")) + removeMotCleAvecErreur(jdc,"STAT_NON_LINE","VARI_COMM") + moveMotCleFromFactToFactMulti(jdc,"DYNA_NON_LINE","CONVERGENCE","RESI_INTE_RELA",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"DYNA_NON_LINE","CONVERGENCE","ITER_INTE_MAXI",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"DYNA_NON_LINE","CONVERGENCE","ITER_INTE_PAS",("COMP_INCR","COMP_ELAS")) + moveMotCleFromFactToFactMulti(jdc,"DYNA_NON_LINE","CONVERGENCE","RESO_INTE",("COMP_INCR","COMP_ELAS")) + removeMotCleAvecErreur(jdc,"DYNA_NON_LINE","VARI_COMM") + + dStatNonLine={"ELAS":"ELAS_THER"} + lavertit=("ELAS") + ChangementValeurDsMCFAvecAvertissement(jdc,"STAT_NON_LINE","COMP-INCR","RELATION_KIT",dStatNonLine,lavertit) + + lavertit=("CHABOCHE","ASSE_COMBU") + dchaboche={"CHABOCHE":"VMIS_CIN1_CHAB","ASSE_COMBU":"XXX_IRA"} + ChangementValeurDsMCFAvecAvertissement(jdc,"STAT_NON_LINE","COMP_INCR","RELATION",dchaboche,lavertit) + + ####################### traitement DEFI_MATERIAU ####################### + renameMotCle(jdc,"DEFI_MATERIAU","LEMAITRE","LEMAITRE_IRRA") + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","QSR_K",("LEMAITRE_IRRA",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","BETA",("LEMAITRE_IRRA",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","PHI_ZERO",("LEMAITRE_IRRA",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","L",("LEMAITRE_IRRA",)) + removeMotCle(jdc,"DEFI_MATERIAU","FLU_IRRA") + renameMotCleAvecErreur(jdc,"DEFI_MATERIAU","CHABOCHE","CINx_CHAB") + + ####################### traitement DEFI_MATERIAU ####################### + renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","A","GRAN_A") + renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","B","GRAN_B") + renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","S","GRAN_S") + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_A",("LEMAITRE_IRRA",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_B",("LEMAITRE_IRRA",)) + 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",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","CABLE","RHO",("ELAS",)) + moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","CABLE","ALPHA",("ELAS",)) + AjouteMotClefDansFacteurSiRegle(jdc,"DEFI_MATERIAU","ELAS","NU=0.,",((("ELAS","NU"),"nexistepasMCsousMCF"),)) + + ####################### traitement IMPR_CO ####################### + chercheOperInsereFacteurSiRegle(jdc,"IMPR_CO","CONCEPT",((("CO",),"existe"),)) + moveMotClefInOperToFact(jdc,"IMPR_CO","CO","CONCEPT") + renameMotCleInFact(jdc,"IMPR_CO","CONCEPT","CO","NOM") + + ####################### traitement DEFI_SQUELETTE ####################### + chercheOperInsereFacteurSiRegle(jdc,"DEFI_SQUELETTE","CYCLIQUE",((("MODE_CYCL",),"existe"),)) + moveMotClefInOperToFact(jdc,"DEFI_SQUELETTE","MODE_CYCL","CYCLIQUE") + + ####################### traitement AFFE_CHAR_* ####################### + removeMotCle(jdc,"AFFE_CHAR_MECA","VERI_DDL") + removeMotCle(jdc,"AFFE_CHAR_MECA","SECH_CALCULEE") + removeMotCle(jdc,"AFFE_CHAR_MECA","HYDR_CALCULEE") + removeMotCle(jdc,"AFFE_CHAR_THER_F","VERI_DDL") + removeMotCle(jdc,"AFFE_CHAR_THER","VERI_DDL") + + 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) + # + dtheta={"CALC_G_LAGR":"G_LAGR_GLOB", "G_BILINEAIRE":"G_BILI_GLOB", "CALC_G_MAX":"G_MAX_GLOB","CALC_G":"CALC_G_GLOB"} + # Attention si le defaut doit generer un avertissement Il faut le mettre comme dernier mot de la liste + lavertit=("CALC_G_LAGR","CALC_G","defaut") + ChangementValeurAvecAvertissement(jdc,"CALC_G_THETA_T","OPTION",dtheta,lavertit) + renameOper(jdc,"CALC_G_LOCAL_T","CALC_G") + renameOper(jdc,"CALC_G_THETA_T","CALC_G") + + # Attention cela necessite un traitement particulier et ne peut pas etre generalise tel quel + # Attention egalement doit etre fait avant le regroupement dans THETA + calcG.traitementRayon(jdc) + renameMotCle(jdc,"CALC_G","THETA","THETA_OLD") + chercheOperInsereFacteur(jdc,"CALC_G","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","THETA_OLD","THETA") + renameMotCleInFact(jdc,"CALC_G","THETA","THETA_OLD","THETA") + + moveMotClefInOperToFact(jdc,"CALC_G","FOND_FISS","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","R_INF_FO","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","R_SUP_FO","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","R_INF","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","R_SUP","THETA") + moveMotClefInOperToFact(jdc,"CALC_G","FISSURE","THETA") + + ####################### 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"),)) + + ####################### traitement PROJ_MESU_MODAL ####################### + removeMotCleInFact(jdc,"PROJ_MESU_MODAL","MODELE_MESURE","NOM_PARA") + removeMotCleInFactSiRegleAvecErreur(jdc,"AFFE_CHAR_MECA","CONTACT","FROTTEMENT",((("CONTACT","METHODE","CONTRAINTE",jdc),"MCsousMCFaPourValeur"),)) + + ####################### traitement CALC_ELEM / CALC_NO ####################### + dcalcelemno={"ERRE_ELGA_NORE":"ERRE_ELEM_SIGM","ERRE_ELEM_NOZ1":"ERZ1_ELEM_SIGM","ERRE_ELEM_NOZ2":"ERZ2_ELEM_SIGM","ERRE_ELNO_ELGA":"ERRE_ELNO_ELEM","ERRE_NOEU_ELGA":"ERRE_NOEU_ELEM","ERTH_ELEM_TEMP":"ERRE_ELEM_TEMP","ERTH_ELNO_ELEM":"ERRE_ELNO_ELEM"} + ChangementValeur(jdc,"CALC_ELEM","OPTION",dcalcelemno) + ChangementValeur(jdc,"CALC_NO","OPTION",dcalcelemno) + ChangementValeurDsMCF(jdc,"IMPR_RESU","RESU","NOM_CHAM",dcalcelemno) + ChangementValeur(jdc,"TEST_RESU","RESU",dcalcelemno) + removeMotCleAvecErreur(jdc,"TEST_RESU","UNITE") + + + ####################### traitement EXTR_MODE ####################### + AjouteMotClefDansFacteurSiRegle(jdc,"EXTR_MODE","FILTRE_MODE","SEUIL=1.E-3", ((("FILTRE_MODE","CRIT_EXTR",),"existeMCsousMCF"),(("FILTRE_MODE","SEUIL",),"nexistepasMCsousMCF"))) + + ####################### traitement DYNA_TRAN_EXPLI ####################### + chercheOperInsereFacteur(jdc,"DYNA_TRAN_EXPLI","DIFF_CENT") + + ####################### traitement CREA_RESU ####################### + dcrearesu={"HYDR_ELGA":"HYDR_NOEU_ELGA"} + lavertit=("HYDR_ELGA",) + ChangementValeur(jdc,"CREA_RESU","NOM_CHAM",dcrearesu,lavertit) + + ####################### traitement DEBUT ####################### + removeMotCleSiRegle(jdc,"DEBUT","BASE",((("BASE","FICHIER","LOCALE",jdc),"MCsousMCFaPourValeur"),)) + + ####################### traitement DEFI_THER_JOULE ####################### + removeCommande(jdc,"DEFI_THER_JOULE") + + ####################### traitement CALC_CHAM_ELEM ####################### + removeCommandeSiRegleAvecErreur(jdc,"CALC_CHAM_ELEM",((("OPTION","SOUR_ELGA_ELEC",jdc),"MCaPourValeur"),)) + + ####################### traitement MACR_LIGNE_COUPE ####################### + AppelleMacroSelonValeurConcept(jdc,"MACR_LIGN_COUPE",("LIGN_COUPE","TABLE","CO")) + + ####################### traitement MODI_MAILLAGE ####################### + removeMotCle(jdc,"MODI_MAILLAGE","MODELE") + + ####################### traitement LIRE_TABLE ####################### + removeMotCle(jdc,"LIRE_TABLE","TYPE_TABLE") + + ####################### traitement POST_SIMPLIFIE ####################### + removeCommande(jdc,"POST_SIMPLIFIE") + + ####################### traitement AFFE_MATERIAU ####################### + removeMotCleInFact(jdc,"AFFE_MATERIAU","AFFE","SECH_REF") + + + f=open(outfile,'w') + f.write(jdc.getSource()) + f.close() + + #hdlr.close() + #logging.shutdown() + log.ferme(hdlr) + +def main(): + parser = optparse.OptionParser(usage=usage) + + parser.add_option('-i','--infile', dest="infile", default='toto.comm', + help="Le fichier à traduire") + parser.add_option('-o','--outfile', dest="outfile", default='tutu.comm', + help="Le fichier traduit") + + options, args = parser.parse_args() + traduc(options.infile,options.outfile) + +if __name__ == '__main__': + main() +