Salome HOME
Traducteur devient Traducteur2 ( python 2)
[tools/eficas.git] / Traducteur3 / demosRN.py
diff --git a/Traducteur3/demosRN.py b/Traducteur3/demosRN.py
new file mode 100755 (executable)
index 0000000..477603f
--- /dev/null
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2017   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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+"""
+usage="""usage: %prog [options]
+Typical use is:
+  python traduitV11V12.py --infile=xxxx --outfile=yyyy
+"""
+
+import os, sys
+sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..'))
+
+import optparse
+
+from Traducteur.load   import getJDC
+from Traducteur.mocles import parseKeywords
+from Traducteur.removemocle  import *
+from Traducteur.renamemocle  import *
+from Traducteur.renamemocle  import *
+from Traducteur.inseremocle  import *
+from Traducteur.changeValeur import *
+from Traducteur.movemocle    import *
+from Traducteur.dictErreurs  import *
+from Traducteur.regles import pasDeRegle
+from Traducteur import log
+
+
+
+atraiter=(
+          "Genere_Une_Erreur_Traduction",
+          "RodBank",
+          "Assembly",
+          "Techno_data",
+          "Model_data",
+          )
+
+dict_erreurs={
+              "Genere_Une_Erreur_Traduction":"Message pour test de genereErreurpourCommande ",
+              }
+
+sys.dict_erreurs=dict_erreurs
+
+def traduc(infile,outfile,flog=None):
+
+    hdlr=log.initialise(flog)
+    jdc=getJDC(infile,atraiter)
+    root=jdc.root
+
+    #Parse les mocles des commandes
+    parseKeywords(root)
+
+    #  genere une erreur si on trouve la commande dans le jdc  #
+    genereErreurPourCommande(jdc,"Genere_Une_Erreur_Traduction")
+
+    f=open(outfile,'w')
+    f.write(jdc.getSource())
+    f.close()
+
+    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")
+
+    parser.add_option('-l','--logfile', dest="flog", default='log.txt',
+        help="fichier de log")
+
+    options, args = parser.parse_args()
+    traduc(options.infile,options.outfile,options.flog)
+
+if __name__ == '__main__':
+    main()