X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Feficas_go.py;h=5ab31e0bf8108a6988c2cf1ada40fa6db7219d64;hb=4bd8d1e0738d27448fc887a4d99ef85eb469da33;hp=d281e90722d3fa28a3ca6107c66643ccc6576e8b;hpb=cdd358f4041f957701ac10d86766a85baaef4f78;p=tools%2Feficas.git diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py old mode 100644 new mode 100755 index d281e907..5ab31e0b --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -1,38 +1,45 @@ #!/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 # -# ====================================================================== +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + # Modules Python +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,"UiQT4") +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 PyQt4.QtGui import * -def lance_eficas(code=None,fichier=None,ssCode=None,multi=False): +def lance_eficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'): """ Lance l'appli EFICAS """ @@ -40,10 +47,11 @@ def lance_eficas(code=None,fichier=None,ssCode=None,multi=False): from Editeur import session options=session.parse(sys.argv) if options.code!= None : code=options.code + if options.ssCode!= None : ssCode=options.ssCode - from qtEficas import Appli + from .qtEficas import Appli app = QApplication(sys.argv) - Eficas=Appli(code=code,ssCode=ssCode,multi=multi) + Eficas=Appli(code=code,ssCode=ssCode,multi=multi,langue=langue) Eficas.show() res=app.exec_() @@ -55,48 +63,110 @@ def lance_eficas_ssIhm(code=None,fichier=None,ssCode=None,version=None): 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) - code=options.code + 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 - app = QApplication(sys.argv) - Eficas=Appli(code=code,ssCode=ssCode) + from .qtEficas import Appli + Eficas=Appli(code=code,ssCode=ssCode,ssIhm=True) - from ssIhm import QWParentSSIhm + from .ssIhm import QWParentSSIhm parent=QWParentSSIhm(code,Eficas,version) - import readercata + from . import readercata if not hasattr ( Eficas, 'readercata'): monreadercata = readercata.READERCATA( parent, Eficas ) Eficas.readercata=monreadercata - - from editor import JDCEditor + from .editor import JDCEditor monEditeur=JDCEditor(Eficas,fichier) - print monEditeur.cherche_Groupes() - -def lance_MapToSh(code=None,fichier=None,ssCode='s_polymers_st_1_V1'): - + 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): + #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) + monEditeur.saveFileAs(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) - code=options.code - fichier=options.comm[0] - from qtEficas import Appli + from .qtEficas import Appli app = QApplication(sys.argv) - Eficas=Appli(code=code,ssCode=ssCode) + Eficas=Appli(code=code,ssCode=None) - from ssIhm import QWParentSSIhm - parent=QWParentSSIhm(code,Eficas,None,ssCode) + from .ssIhm import QWParentSSIhm + parent=QWParentSSIhm(code,Eficas,version) - import readercata + from . import readercata if not hasattr ( Eficas, 'readercata'): monreadercata = readercata.READERCATA( parent, Eficas ) Eficas.readercata=monreadercata - from editor import JDCEditor + from .editor import JDCEditor monEditeur=JDCEditor(Eficas,fichier) - texte=monEditeur.run("non") - print texte + 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