X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Feficas_go.py;h=8ca631a543a9330e3df62bdbb40dc0a01d3207d4;hb=0dd3754f2c6ebee6f61a7aa505ed8711dd9ba79e;hp=e79bea8b0439c9ab756fe213a5b6b4d36aa51d46;hpb=7e72a676f0cd6fcb60eb9515ba411fdc6dfabc1a;p=tools%2Feficas.git diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py old mode 100644 new mode 100755 index e79bea8b..8ca631a5 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -1,48 +1,190 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- -# CONFIGURATION MANAGEMENT OF EDF VERSION -# ====================================================================== -# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG -# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY -# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY -# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR -# (AT YOUR OPTION) ANY LATER VERSION. +# Copyright (C) 2007-2013 EDF R&D # -# THIS PROGRAM 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 -# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# 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. # -# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE -# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, -# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# 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 # -# ====================================================================== -""" - Ce module permet de lancer l'application EFICAS en affichant - un ecran Splash pour faire patienter l'utilisateur -""" +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + # Modules Python -import sys -from PyQt4.QtGui import * +from __future__ import absolute_import +from __future__ import print_function +try : + from builtins import str +except : pass + +from PyQt5.QtWidgets import QApplication + +import sys,os +repIni=os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"..")) +ihmQTDir=os.path.join(repIni,"UiQT5") +editeurDir=os.path.join(repIni,"Editeur") +ihmDir=os.path.join(repIni,"InterfaceQT4") + +if ihmDir not in sys.path : sys.path.append(ihmDir) +if ihmQTDir not in sys.path : sys.path.append(ihmQTDir) +if editeurDir not in sys.path :sys.path.append(editeurDir) -from Editeur import import_code -from Editeur import session -from qtEficas import Appli -def lance_eficas(code=None,fichier=None): +def lance_eficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'): """ Lance l'appli EFICAS """ # Analyse des arguments de la ligne de commande + from Editeur import session options=session.parse(sys.argv) - code=options.code + if options.code!= None : code=options.code + if options.ssCode!= None : ssCode=options.ssCode + from InterfaceQT4.qtEficas import Appli app = QApplication(sys.argv) - Eficas=Appli(code=code) + Eficas=Appli(code=code,ssCode=ssCode,multi=multi,langue=langue) Eficas.show() - res=app.exec_() sys.exit(res) + +def lance_eficas_ssIhm(code=None,fichier=None,ssCode=None,version=None,debug=False): + """ + Lance l'appli EFICAS pour trouver les noms des groupes + """ + # Analyse des arguments de la ligne de commande + from Editeur import session + options=session.parse(sys.argv) + if version!=None and options.cata==None : options.cata=version + if fichier==None : fichier=options.comm[0] + if code == None : code=options.code + + from .qtEficas import Appli + Eficas=Appli(code=code,ssCode=ssCode,ssIhm=True) + + from .ssIhm import QWParentSSIhm + parent=QWParentSSIhm(code,Eficas,version) + + from . import readercata + if not hasattr ( Eficas, 'readercata'): + monreadercata = readercata.READERCATA( parent, Eficas ) + Eficas.readercata=monreadercata + + from .editor import JDCEditor + monEditeur=JDCEditor(Eficas,fichier) + return monEditeur + +def lance_eficas_ssIhm_cherche_Groupes(code=None,fichier=None,ssCode=None,version=None): + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + print((monEditeur.cherche_Groupes())) + +def lance_eficas_ssIhm_cherche_cr(code=None,fichier=None,ssCode=None,version=None): + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + print((monEditeur.jdc.cr)) + +def lance_eficas_ssIhm_reecrit(code=None,fichier=None,ssCode=None,version=None,ou=None,cr=False,debug=False,leger=False): + #print 'lance_eficas_ssIhm_reecrit', fichier + monEditeur=lance_eficas_ssIhm(code,fichier,ssCode,version) + if ou == None : + fileName=fichier.split(".")[0]+"_reecrit.comm" + fn=fichier.split(".")[0]+"_cr.txt" + else : + f=fichier.split(".")[0]+"_reecrit.comm" + f1=os.path.basename(f) + fn=fichier.split(".")[0]+"_cr.txt" + f2=os.path.basename(fn) + fileName=os.path.join(ou,f1) + fileCr=os.path.join(ou,f2) + debut=False + if debug : + import cProfile, pstats, StringIO + pr = cProfile.Profile() + pr.enable() + monEditeur.saveFileAs(fileName=fileName) + pr.disable() + s = StringIO.StringIO() + sortby = 'cumulative' + ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + ps.print_stats() + print (s.getvalue()) + + elif not leger : monEditeur.saveFileAs(fileName=fileName) + else : monEditeur.saveFileLegerAs(fileName=fileName) + if cr: + f = open(fileCr, 'w') + f.write(str(monEditeur.jdc.report())) + f.close() + +def lance_eficas_param(code='Adao',fichier=None,version='V0',macro='ASSIMILATION_STUDY'): + """ + Lance l'appli EFICAS pour trouver les noms des groupes + """ + # Analyse des arguments de la ligne de commande + from Editeur import session + options=session.parse(sys.argv) + + from .qtEficas import Appli + app = QApplication(sys.argv) + Eficas=Appli(code=code,ssCode=None) + + from .ssIhm import QWParentSSIhm + parent=QWParentSSIhm(code,Eficas,version) + + from . import readercata + if not hasattr ( Eficas, 'readercata'): + monreadercata = readercata.READERCATA( parent, Eficas ) + Eficas.readercata=monreadercata + + from .editor import JDCEditor + monEditeur=JDCEditor(Eficas,fichier) + texte=loadJDC(fichier) + parameters=getJdcParameters(texte,macro) + return parameters + +def getJdcParameters(jdc,macro): + """ + This function converts the data from the specified macro of the + specified jdc text to a python dictionnary whose keys are the + names of the data of the macro. + """ + context = {} + source = "def args_to_dict(**kwargs): return kwargs \n" + source+= "%s = _F = args_to_dict \n"%macro + source+= "parameters="+jdc+" \n" + source+= "context['parameters'] = parameters \n" + code = compile(source, 'file.py', 'exec') + eval(code) + parameters = context['parameters'] + return parameters + +def loadJDC(filename): + """ + This function loads the text from the specified JdC file. A JdC + file is the persistence file of Eficas (*.comm). + """ + fcomm=open(filename,'r') + jdc = "" + for line in fcomm.readlines(): + if not (line[0]=='#'): + jdc+="%s"%line + + # Warning, we have to make sure that the jdc comes as a simple + # string without any extra spaces/newlines + return jdc.strip() + +if __name__ == "__main__": + import sys + sys.path.insert(0,os.path.abspath(os.path.join(os.getcwd(),'..'))) + lance_eficas(code=None,fichier=None,ssCode=None,multi=True) + +