Salome HOME
fce867859c8d9ce6dbc84dffddbd934072b3d774
[tools/eficas.git] / InterfaceQT4 / gereTraduction.py
1 # Copyright (C) 2007-2013   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 PyQt4 import *
20 from PyQt4.QtGui import *
21 from PyQt4.QtCore import *
22 import os
23 from Extensions.i18n import tr
24
25
26 def traduction(directPath,editor,version):
27     if version == "V9V10" : 
28        from Traducteur import traduitV9V10 
29        suffixe="v10.comm"
30     if version == "V10V11" :
31        from Traducteur import traduitV10V11
32        suffixe="v11.comm"
33     if version == "V11V12" :
34        from Traducteur import traduitV11V12
35        suffixe="v12.comm"
36
37     fn = QFileDialog.getOpenFileName( 
38                         editor.appliEficas,
39                         tr('Traduire Fichier'),
40                         QString(directPath) ,
41                         tr('Fichiers JDC  (*.comm);;''Tous les Fichiers (*)'))
42
43
44     FichieraTraduire=str(fn)
45     if (FichieraTraduire == "" or FichieraTraduire == () ) : return
46     i=FichieraTraduire.rfind(".")
47     Feuille=FichieraTraduire[0:i]
48     FichierTraduit=Feuille+suffixe
49
50     i=Feuille.rfind("/")
51     directLog=Feuille[0:i]
52     log=directLog+"/convert.log"
53     os.system("rm -rf "+log)
54     os.system("rm -rf "+FichierTraduit)
55
56     qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
57     if version == "V9V10" : traduitV9V10.traduc(FichieraTraduire,FichierTraduit,log)
58     if version == "V10V11" : traduitV10V11.traduc(FichieraTraduire,FichierTraduit,log)
59     if version == "V11V12" : traduitV11V12.traduc(FichieraTraduire,FichierTraduit,log)
60     qApp.setOverrideCursor(QCursor(Qt.ArrowCursor))
61
62     Entete=tr("Fichier Traduit : %s\n\n",str(FichierTraduit))
63     if  os.stat(log)[6] != 0L :
64         f=open(log)
65         texte= f.read()
66         f.close()
67     else :
68        texte = Entete  
69        commande="diff "+FichieraTraduire+" "+FichierTraduit+" >/dev/null"
70        try :
71          if os.system(commande) == 0 :
72             texte = texte + tr("Pas de difference entre le fichier origine et le fichier traduit")
73        except :
74          pass
75
76     from monVisu import DVisu
77     titre = "conversion de "+ FichieraTraduire
78     monVisuDialg=DVisu(parent=editor.appliEficas,fl=0)
79     monVisuDialg.setWindowTitle(titre)
80     monVisuDialg.TB.setText(texte)
81     monVisuDialg.show()
82