Salome HOME
modif pour MT
[tools/eficas.git] / InterfaceQT4 / gereTraduction.py
1 # Copyright (C) 2007-2017   EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 from __future__ import absolute_import
20 try :
21    from builtins import str
22 except : pass
23
24 from PyQt5.QtWidgets import  QFileDialog, QApplication
25
26 import os
27 from Extensions.i18n import tr
28
29
30 def traduction(directPath,editor,version):
31     if version == "V9V10" : 
32        from Traducteur import traduitV9V10 
33        suffixe="v10.comm"
34     if version == "V10V11" :
35        from Traducteur import traduitV10V11
36        suffixe="v11.comm"
37     if version == "V11V12" :
38        from Traducteur import traduitV11V12
39        suffixe="v12.comm"
40
41     fn = QFileDialog.getOpenFileName( 
42                         editor.appliEficas,
43                         tr('Traduire Fichier'),
44                         directPath ,
45                         tr('Fichiers JDC  (*.comm);;''Tous les Fichiers (*)'))
46
47
48     fn=fn[0]
49     FichieraTraduire=str(fn)
50     if (FichieraTraduire == "" or FichieraTraduire == () ) : return
51     i=FichieraTraduire.rfind(".")
52     Feuille=FichieraTraduire[0:i]
53     FichierTraduit=Feuille+suffixe
54
55     i=Feuille.rfind("/")
56     directLog=Feuille[0:i]
57     log=directLog+"/convert.log"
58     os.system("rm -rf "+log)
59     os.system("rm -rf "+FichierTraduit)
60
61     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
62     if version == "V9V10" : traduitV9V10.traduc(FichieraTraduire,FichierTraduit,log)
63     if version == "V10V11" : traduitV10V11.traduc(FichieraTraduire,FichierTraduit,log)
64     if version == "V11V12" : traduitV11V12.traduc(FichieraTraduire,FichierTraduit,log)
65     QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor))
66
67     Entete=tr("Fichier Traduit : %s\n\n",str(FichierTraduit))
68     if  os.stat(log)[6] != 0 :
69         f=open(log)
70         texte= f.read()
71         f.close()
72     else :
73        texte = Entete  
74        commande="diff "+FichieraTraduire+" "+FichierTraduit+" >/dev/null"
75        try :
76          if os.system(commande) == 0 :
77             texte = texte + tr("Pas de difference entre le fichier origine et le fichier traduit")
78        except :
79          pass
80
81     from .monVisu import DVisu
82     titre = "conversion de "+ FichieraTraduire
83     monVisuDialg=DVisu(parent=editor.appliEficas,fl=0)
84     monVisuDialg.setWindowTitle(titre)
85     monVisuDialg.TB.setText(texte)
86     monVisuDialg.show()
87