From: Pascale Noyret Date: Mon, 11 Sep 2006 15:23:59 +0000 (+0000) Subject: PN pour sauvegarde X-Git-Tag: CC_param_poursuite~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a80851fd797dceebdb61f8ecc1afd313b1d872d0;p=modules%2Feficas.git PN pour sauvegarde --- diff --git a/Traducteur/calcG.py b/Traducteur/calcG.py new file mode 100644 index 00000000..e8e48aa6 --- /dev/null +++ b/Traducteur/calcG.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +from parseur import FactNode + +dict_commande={} +dict_contexte={} + +#-------------------------------------------------------------------------- +def traitementRayon(jdc): +#-------------------------------------------------------------------------- + for c in jdc.root.childNodes: + if c.name != "DEFI_FONCTION" : continue + monTexte=jdc.getLines()[c.lineno-1] + monNomVariable=monTexte.split("=")[0] + aExecuter=monNomVariable+'=0' + dict_commande[monNomVariable]=c + exec aExecuter in dict_contexte + liste_MC=(("CALC_G","R_INF_FO"),("CALC_G","R_SUP_FO"),("CALC_G","MODULE_FO")) + liste_achanger = chercheValeurSelonGenea2 (jdc,liste_MC) + for item in liste_achanger : + commande=dict_commande[item] + changeValeurABSCNiveau1(commande,jdc) + +#---------------------------------- +def changeValeurABSCNiveau1(c,jdc): +#---------------------------------- + for child in c.childNodes: + if child.name != "NOM_PARA":continue + MonTexte=child.getText(jdc) + if len(MonTexte.splitlines()) > 1 : + print "Le Traducteur ne sait pas gerer" + assert(0) + MonTexte=jdc.getLines()[child.lineno-1] + debut=MonTexte.find("NOM_PARA") + debChaine=MonTexte[0:debut+8] + ancien=MonTexte[debut+8:] + egal,nomval,fin=ancien.split("'",2) + nouvelleLigne=debChaine+egal+"'ABSC'"+fin + jdc.getLines()[child.lineno-1]=nouvelleLigne + return + +#-------------------------------------------------------------------------- +def chercheValeurSelonGenea2(jdc,liste_cherche_valeur): +# +#-------------------------------------------------------------------------- + liste_valeurs=[] + for genea in liste_cherche_valeur: + profondeur=len(genea) + if profondeur > 2 : + print "la methode chercheValeurSelonGenea ne convient" + print "pas pour cette généalogie" + assert(0) + command=genea[0] + fact=genea[1] + + d={} + for c in jdc.root.childNodes: + if c.name != command:continue + for mc in c.childNodes: + if mc.name != fact:continue + MonTexte=mc.getText(jdc) + #try : + if ( 1) : + exec MonTexte in dict_contexte + monNomVariable=MonTexte.split("=")[1][0:-1] + if monNomVariable not in liste_valeurs : liste_valeurs.append(monNomVariable) + #except : + else : + pass + liste_valeurs + return liste_valeurs + diff --git a/Traducteur/jdcparser.py b/Traducteur/jdcparser.py index d150315c..caa70cf0 100644 --- a/Traducteur/jdcparser.py +++ b/Traducteur/jdcparser.py @@ -16,10 +16,11 @@ import removemocle import renamemocle import movemocle import inseremocle +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", + "AFFE_CHAR_THER_F","IMPR_CO","DEFI_SQUELETTE","DEFI_FONCTION", ) #atraiter=("CALC_FONCTION","IMPR_GENE","STAT_NON_LINE","DEFI_MATERIAU", @@ -89,9 +90,25 @@ def traduc(infile,outfile): movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_S",("LEMAITRE_IRRA",)) removemocle.removeMotCle(jdc,"DEFI_MATERIAU","GRAN_IRRA") + inseremocle.chercheOperInsereFacteur(jdc,"IMPR_CO","CONCEPT") + movemocle.moveMotClefInOperToFact(jdc,"IMPR_CO","CO","CONCEPT") + renamemocle.renameMotCleInFact(jdc,"IMPR_CO","CONCEPT","CO","NOM") + + inseremocle.chercheOperInsereFacteur(jdc,"DEFI_SQUELETTE","CYCLIQUE") + movemocle.moveMotClefInOperToFact(jdc,"DEFI_SQUELETTE","MODE_CYCL","CYCLIQUE") + + removemocle.removeMotCle(jdc,"AFFE_CHAR_MECA","VERI_DDL") + removemocle.removeMotCle(jdc,"AFFE_CHAR_THER_F","VERI_DDL") renamemocle.renameOper(jdc,"CALC_G_LOCAL_T","CALC_G") renamemocle.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) + + renamemocle.renameMotCle(jdc,"CALC_G","THETA","THETA_OLD") inseremocle.chercheOperInsereFacteur(jdc,"CALC_G","THETA") movemocle.moveMotClefInOperToFact(jdc,"CALC_G","THETA_OLD","THETA") @@ -102,16 +119,6 @@ def traduc(infile,outfile): movemocle.moveMotClefInOperToFact(jdc,"CALC_G","R_SUP_FO","THETA") inseremocle.chercheOperInsereFacteurSiRegle(jdc,"CALC_G","LISSAGE",((("DEGRE",),"existe"),)) movemocle.moveMotClefInOperToFact(jdc,"CALC_G","DEGRE","LISSAGE") - - inseremocle.chercheOperInsereFacteur(jdc,"IMPR_CO","CONCEPT") - movemocle.moveMotClefInOperToFact(jdc,"IMPR_CO","CO","CONCEPT") - renamemocle.renameMotCleInFact(jdc,"IMPR_CO","CONCEPT","CO","NOM") - - inseremocle.chercheOperInsereFacteur(jdc,"DEFI_SQUELETTE","CYCLIQUE") - movemocle.moveMotClefInOperToFact(jdc,"DEFI_SQUELETTE","MODE_CYCL","CYCLIQUE") - - removemocle.removeMotCle(jdc,"AFFE_CHAR_MECA","VERI_DDL") - removemocle.removeMotCle(jdc,"AFFE_CHAR_THER_F","VERI_DDL") f=open(outfile,'w') f.write(jdc.getSource())