2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2013 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 repIni=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),".."))
25 ihmQTDir=os.path.join(repIni,"UiQT4")
26 editeurDir=os.path.join(repIni,"Editeur")
27 ihmDir=os.path.join(repIni,"InterfaceQT4")
28 if ihmDir not in sys.path : sys.path.append(ihmDir)
29 if ihmQTDir not in sys.path : sys.path.append(ihmQTDir)
30 if editeurDir not in sys.path :sys.path.append(editeurDir)
32 from PyQt4.QtGui import *
34 def lance_eficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'):
38 # Analyse des arguments de la ligne de commande
39 from Editeur import session
40 options=session.parse(sys.argv)
41 if options.code!= None : code=options.code
42 if options.ssCode!= None : ssCode=options.ssCode
44 from qtEficas import Appli
45 from Extensions import localisation
46 app = QApplication(sys.argv)
47 localisation.localise(app,langue)
48 Eficas=Appli(code=code,ssCode=ssCode,multi=multi,langue=langue)
55 def lance_eficas_ssIhm(code=None,fichier=None,ssCode=None,version=None):
57 Lance l'appli EFICAS pour trouver les noms des groupes
59 # Analyse des arguments de la ligne de commande
60 from Editeur import session
61 options=session.parse(sys.argv)
62 if version!=None and options.cata==None : options.cata=version
63 if fichier==None : fichier=options.comm[0]
64 if code == None : code=options.code
66 from qtEficas import Appli
67 app = QApplication(sys.argv)
68 Eficas=Appli(code=code,ssCode=ssCode,ssIhm=True)
70 from ssIhm import QWParentSSIhm
71 parent=QWParentSSIhm(code,Eficas,version)
74 if not hasattr ( Eficas, 'readercata'):
75 monreadercata = readercata.READERCATA( parent, Eficas )
76 Eficas.readercata=monreadercata
78 from editor import JDCEditor
79 monEditeur=JDCEditor(Eficas,fichier)
82 def lance_eficas_ssIhm_cherche_Groupes(code=None,fichier=None,ssCode=None,version=None):
83 monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version)
84 print monEditeur.cherche_Groupes()
86 def lance_eficas_ssIhm_cherche_cr(code=None,fichier=None,ssCode=None,version=None):
87 monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version)
88 print monEditeur.jdc.cr
90 def lance_eficas_ssIhm_reecrit(code=None,fichier=None,ssCode=None,version=None):
91 monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version)
93 fileName=fichier.split(".")[0]+"_reecrit.comm"
94 monEditeur.saveFileAs(fileName=fileName)
96 def lance_eficas_param(code='Adao',fichier=None,version='V0',macro='ASSIMILATION_STUDY'):
98 Lance l'appli EFICAS pour trouver les noms des groupes
100 # Analyse des arguments de la ligne de commande
101 from Editeur import session
102 options=session.parse(sys.argv)
104 from qtEficas import Appli
105 app = QApplication(sys.argv)
106 Eficas=Appli(code=code,ssCode=None)
108 from ssIhm import QWParentSSIhm
109 parent=QWParentSSIhm(code,Eficas,version)
112 if not hasattr ( Eficas, 'readercata'):
113 monreadercata = readercata.READERCATA( parent, Eficas )
114 Eficas.readercata=monreadercata
116 from editor import JDCEditor
117 monEditeur=JDCEditor(Eficas,fichier)
118 texte=loadJDC(fichier)
119 parameters=getJdcParameters(texte,macro)
122 def getJdcParameters(jdc,macro):
124 This function converts the data from the specified macro of the
125 specified jdc text to a python dictionnary whose keys are the
126 names of the data of the macro.
129 source = "def args_to_dict(**kwargs): return kwargs \n"
130 source+= "%s = _F = args_to_dict \n"%macro
131 source+= "parameters="+jdc+" \n"
132 source+= "context['parameters'] = parameters \n"
133 code = compile(source, 'file.py', 'exec')
135 parameters = context['parameters']
138 def loadJDC(filename):
140 This function loads the text from the specified JdC file. A JdC
141 file is the persistence file of Eficas (*.comm).
143 fcomm=open(filename,'r')
145 for line in fcomm.readlines():
146 if not (line[0]=='#'):
149 # Warning, we have to make sure that the jdc comes as a simple
150 # string without any extra spaces/newlines
153 if __name__ == "__main__":
155 sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..')))
156 lance_eficas(code=None,fichier=None,ssCode=None,multi=True)