From: Pascale Noyret Date: Fri, 21 Dec 2012 15:09:09 +0000 (+0000) Subject: Pour Jean-Philippe X-Git-Tag: V6_6_0p1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87123c22284ccfd8c0dbfbc8c1f71d7b5230a88a;p=tools%2Feficas.git Pour Jean-Philippe --- diff --git a/Adao/qtDico.py b/Adao/qtDico.py new file mode 100755 index 00000000..5d652361 --- /dev/null +++ b/Adao/qtDico.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2012 EDF R&D +# +# 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. +# +# 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 +# +""" + Ce module sert à lancer EFICAS configuré pour Code_Aster +""" +# Modules Python + +# Modules Eficas +import prefs +name='prefs_'+prefs.code +__import__(name) + +from InterfaceQT4 import eficas_go + +eficas_go.lance_eficas_param(code=prefs.code,fichier="/local/noyret/Eficas_ASTER/adao.comm",version='V0') diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index c561ee6b..5cba619c 100644 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -55,6 +55,7 @@ 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 @@ -75,19 +76,17 @@ def lance_eficas_ssIhm(code=None,fichier=None,ssCode=None,version=None): monEditeur=JDCEditor(Eficas,fichier) print monEditeur.cherche_Groupes() -def lance_eficas_param(code='MAP',fichier='/local/noyret/Eficas_MAP/creation.comm',ssCode='Creation',version='creation'): +def lance_eficas_param(code='Adao',fichier='/local/noyret/Eficas_ASTER/adao.comm',version='V0'): """ 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 options.code!= None : code=options.code - if options.ssCode!= None : ssCode=options.ssCode 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,version) @@ -97,10 +96,43 @@ def lance_eficas_param(code='MAP',fichier='/local/noyret/Eficas_MAP/creation.com monreadercata = readercata.READERCATA( parent, Eficas ) Eficas.readercata=monreadercata - from editor import JDCEditor monEditeur=JDCEditor(Eficas,fichier) - print monEditeur.cherche_Dico() + texte=monEditeur.get_text_JDC('python') + texte2='jdc+"'+loadJDC(fichier)+'"' + print texte2 + parameters=getJdcParameters(texte,'ASSIMILATION_STUDY') + #print getJdcParameters(texte,'CHECKING_STUDY') + +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(): + 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