+#!/usr/bin/env python
# -*- coding: utf-8 -*-
+"""
+"""
+usage="""usage: %prog [options]
+Typical use is:
+ python jdcparser.py --infile=xxxx --outfile=yyyy
+"""
import log
+import optparse
from load import getJDC
from mocles import parseKeywords
"CALC_G_LOCAL_T","CALC_G_THETA_T","CALC_G",
)
-
#atraiter=("CALC_FONCTION","IMPR_GENE","STAT_NON_LINE","DEFI_MATERIAU",
# "CALC_G_LOCAL_T","CALC_G_THETA_T","CALC_G",)
#atraiter=( "CALC_G_LOCAL_T","CALC_G_THETA_T","CALC_G",)
#atraiter=( "IMPR_GENE",)
-filename="toto.comm"
-jdc=getJDC(filename,atraiter)
-root=jdc.root
-
-#Parse les mocles des commandes
-parseKeywords(root)
-
-
-#removemocle.removeMotCleInFact(jdc,"AFFE_MATERIAU","AFFE","TOUT")
-#removemocle.removeMotCle(jdc,"STAT_NONLINE","SOLVEUR")
-#renamemocle.renameMotCleInFact(jdc,"AFFE_MODELE","AFFE","PHENOMENE","TOTO")
-#renamemocle.renameMotCleInFact(jdc,"AFFE_MODELE","AFFE","MODELISATION","TITI")
-#renamemocle.renameMotCleInFact(jdc,"DEFI_GROUP","CREA_GROUP_NO","GROUP_MA","TUTU")
-#removemocle.removeMotCle(jdc,"LIRE_MAILLAGE","INFO")
-#removemocle.removeMotCle(jdc,"LIRE_MAILLAGE","UNITE")
-#renamemocle.renameMotCle(jdc,"DEFI_MATERIAU","ELAS","ELASTIC")
-#renamemocle.renameMotCle(jdc,"AFFE_MATERIAU","MAILLAGE","MAILL")
-#removemocle.removeMotCleInFact(jdc,"STAT_NONLINE","SOLV","METHOD")
-#removemocle.removeMotCle(jdc,"STAT_NONLINE","AFFE")
-#renamemocle.renameCommande(jdc,"AFFE_CHAR_MECA","AFFE_CHAR_MECA_PN")
-#renamemocle.renameCommande(jdc,"DEBUT","DEBUT_PN")
-
-# A decommenter a partir d ici
-# les arguments sont jdc,ancien-nom-de-commande,nouveau-nom-de-commande
-renamemocle.renameCommande(jdc,"CALC_FONCTION","INFO_FONCTION")
-
-# Les arguments sont - jdc,
-# - nom de la procedure (pas teste avec autre chose)
-# - nom du mot clef facteur contenant,
-# - nom du mot cle simple
-# Attention ne fonctionne pas pour l instant avec +sieurs occurences du mot cle à déplacer
-movemocle.moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","UNITE")
-movemocle.moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","FORMAT")
-
-# Les arguments sont - jdc
-# - nom de l operateur (pas teste avec autre chose)
-# - nom du mot clef facteur source,
-# - nom du mot cle simple
-# - liste de mots clef facteur arrivée possible
-# Attention ne fonctionne pas pour l instant avec +sieurs occurences du mot cle à déplacer
-movemocle.moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","RESI_INTE_RELA",("COMP_INCR","COMP_ELAS"))
-
-
-renamemocle.renameMotCle(jdc,"DEFI_MATERIAU","LEMAITRE","LEMAITRE_IRRA")
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","QSR_K",("LEMAITRE_IRRA",))
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","BETA",("LEMAITRE_IRRA",))
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","PHI_ZERO",("LEMAITRE_IRRA",))
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","L",("LEMAITRE_IRRA",))
-removemocle.removeMotCle(jdc,"DEFI_MATERIAU","FLU_IRRA")
-
-renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","A","GRAN_A")
-renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","B","GRAN_B")
-renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","S","GRAN_S")
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_A",("LEMAITRE_IRRA",))
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_B",("LEMAITRE_IRRA",))
-movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_S",("LEMAITRE_IRRA",))
-removemocle.removeMotCle(jdc,"DEFI_MATERIAU","GRAN_IRRA")
-
-#renamemocle.renameOper(jdc,"CALC_G_LOCAL_T","CALC_G")
-renamemocle.renameOper(jdc,"CALC_G_THETA_T","CALC_G")
-renamemocle.renameMotCle(jdc,"CALC_G","THETA","THETA_OLD")
-inseremocle.chercheOperInsereFacteur(jdc,"CALC_G","THETA")
-
-movemocle.moveMotClefInOperToFact(jdc,"CALC_G","THETA_OLD","THETA")
-renamemocle.renameMotCleInFact(jdc,"CALC_G","THETA","THETA_OLD","THETA")
-movemocle.moveMotClefInOperToFact(jdc,"CALC_G","FOND_FISS","THETA")
-movemocle.moveMotClefInOperToFact(jdc,"CALC_G","R_INF_FO","THETA")
-movemocle.moveMotClefInOperToFact(jdc,"CALC_G","R_SUP_FO","THETA")
-inseremocle.chercheOperInsereFacteurSiRegle(jdc,"CALC_G","LISSAGE",((("DEGRE",),"existe"),))
-movemocle.moveMotClefInOperToFact(jdc,"CALC_G","DEGRE","LISSAGE")
-
-
-f=open("tutu.comm",'w')
-f.write(jdc.getSource())
-f.close()
+
+def traduc(infile,outfile):
+ jdc=getJDC(infile,atraiter)
+ root=jdc.root
+
+ #Parse les mocles des commandes
+ parseKeywords(root)
+
+ #removemocle.removeMotCleInFact(jdc,"AFFE_MATERIAU","AFFE","TOUT")
+ removemocle.removeMotCle(jdc,"STAT_NON_LINE","MODELE")
+ #removemocle.removeMotCle(jdc,"STAT_NONLINE","SOLVEUR")
+ #renamemocle.renameMotCleInFact(jdc,"AFFE_MODELE","AFFE","PHENOMENE","TOTO")
+ #renamemocle.renameMotCleInFact(jdc,"AFFE_MODELE","AFFE","MODELISATION","TITI")
+ #renamemocle.renameMotCleInFact(jdc,"DEFI_GROUP","CREA_GROUP_NO","GROUP_MA","TUTU")
+ #removemocle.removeMotCle(jdc,"LIRE_MAILLAGE","INFO")
+ #removemocle.removeMotCle(jdc,"LIRE_MAILLAGE","UNITE")
+ #renamemocle.renameMotCle(jdc,"DEFI_MATERIAU","ELAS","ELASTIC")
+ #renamemocle.renameMotCle(jdc,"AFFE_MATERIAU","MAILLAGE","MAILL")
+ #removemocle.removeMotCleInFact(jdc,"STAT_NONLINE","SOLV","METHOD")
+ #removemocle.removeMotCle(jdc,"STAT_NONLINE","AFFE")
+ #renamemocle.renameCommande(jdc,"AFFE_CHAR_MECA","AFFE_CHAR_MECA_PN")
+ #renamemocle.renameCommande(jdc,"DEBUT","DEBUT_PN")
+
+ # A decommenter a partir d ici
+ # les arguments sont jdc,ancien-nom-de-commande,nouveau-nom-de-commande
+ renamemocle.renameCommande(jdc,"CALC_FONCTION","INFO_FONCTION")
+
+ # Les arguments sont - jdc,
+ # - nom de la procedure (pas teste avec autre chose)
+ # - nom du mot clef facteur contenant,
+ # - nom du mot cle simple
+ # Attention ne fonctionne pas pour l instant avec +sieurs occurences du mot cle à déplacer
+ movemocle.moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","UNITE")
+ movemocle.moveMotCleFromFactToFather(jdc,"IMPR_GENE","GENE","FORMAT")
+
+ # Les arguments sont - jdc
+ # - nom de l operateur (pas teste avec autre chose)
+ # - nom du mot clef facteur source,
+ # - nom du mot cle simple
+ # - liste de mots clef facteur arrivée possible
+ # Attention ne fonctionne pas pour l instant avec +sieurs occurences du mot cle à déplacer
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"STAT_NON_LINE","CONVERGENCE","RESI_INTE_RELA",("COMP_INCR","COMP_ELAS"))
+
+
+ renamemocle.renameMotCle(jdc,"DEFI_MATERIAU","LEMAITRE","LEMAITRE_IRRA")
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","QSR_K",("LEMAITRE_IRRA",))
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","BETA",("LEMAITRE_IRRA",))
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","PHI_ZERO",("LEMAITRE_IRRA",))
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","FLU_IRRA","L",("LEMAITRE_IRRA",))
+ removemocle.removeMotCle(jdc,"DEFI_MATERIAU","FLU_IRRA")
+
+ renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","A","GRAN_A")
+ renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","B","GRAN_B")
+ renamemocle.renameMotCleInFact(jdc,"DEFI_MATERIAU","GRAN_IRRA","S","GRAN_S")
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_A",("LEMAITRE_IRRA",))
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_B",("LEMAITRE_IRRA",))
+ movemocle.moveMotCleFromFactToFactMulti(jdc,"DEFI_MATERIAU","GRAN_IRRA","GRAN_S",("LEMAITRE_IRRA",))
+ removemocle.removeMotCle(jdc,"DEFI_MATERIAU","GRAN_IRRA")
+
+ #renamemocle.renameOper(jdc,"CALC_G_LOCAL_T","CALC_G")
+ renamemocle.renameOper(jdc,"CALC_G_THETA_T","CALC_G")
+ renamemocle.renameMotCle(jdc,"CALC_G","THETA","THETA_OLD")
+ inseremocle.chercheOperInsereFacteur(jdc,"CALC_G","THETA")
+
+ movemocle.moveMotClefInOperToFact(jdc,"CALC_G","THETA_OLD","THETA")
+ renamemocle.renameMotCleInFact(jdc,"CALC_G","THETA","THETA_OLD","THETA")
+ movemocle.moveMotClefInOperToFact(jdc,"CALC_G","FOND_FISS","THETA")
+ movemocle.moveMotClefInOperToFact(jdc,"CALC_G","R_INF_FO","THETA")
+ movemocle.moveMotClefInOperToFact(jdc,"CALC_G","R_SUP_FO","THETA")
+ inseremocle.chercheOperInsereFacteurSiRegle(jdc,"CALC_G","LISSAGE",((("DEGRE",),"existe"),))
+ movemocle.moveMotClefInOperToFact(jdc,"CALC_G","DEGRE","LISSAGE")
+
+ f=open(outfile,'w')
+ f.write(jdc.getSource())
+ f.close()
+
+def main():
+ parser = optparse.OptionParser(usage=usage)
+
+ parser.add_option('--infile', dest="infile", default='toto.comm',
+ help="Le fichier à traduire")
+ parser.add_option('--outfile', dest="outfile", default='tutu.comm',
+ help="Le fichier traduit")
+
+ options, args = parser.parse_args()
+ traduc(options.infile,options.outfile)
+
+if __name__ == '__main__':
+ main()
+