From: pascale.noyret Date: Tue, 7 May 2019 15:42:26 +0000 (+0200) Subject: generer le XSD et autre print X-Git-Tag: avantMenage~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c32fd3f4eb56df6d43034e6a44b1f030780c3303;p=tools%2Feficas.git generer le XSD et autre print --- diff --git a/Accas/A_ETAPE.py b/Accas/A_ETAPE.py index a3dbd595..01ba2a03 100644 --- a/Accas/A_ETAPE.py +++ b/Accas/A_ETAPE.py @@ -25,6 +25,5 @@ from Efi2Xsd.MCAccasXsd import X_MCCOMPO class ETAPE(I_ETAPE.ETAPE,V_ETAPE.ETAPE,X_MCCOMPO,N_ETAPE.ETAPE): def __init__(self,oper=None,reuse=None,args={}): - print ('------------- ETAPE accas', oper.nom, args) N_ETAPE.ETAPE.__init__(self,oper,reuse,args) V_ETAPE.ETAPE.__init__(self) diff --git a/Efi2Xsd/AccasXsd.py b/Efi2Xsd/AccasXsd.py index a1a807f9..639ef10b 100755 --- a/Efi2Xsd/AccasXsd.py +++ b/Efi2Xsd/AccasXsd.py @@ -327,8 +327,8 @@ class X_JDC_CATA : def dumpXsd(self): cata = CONTEXT.getCurrentCata() if self.fichierSource != self.module.__file__ : - self.dumpDifferenceModuleMetier() - return + self.texteXSD = self.dumpDifferenceModuleMetier() + return self.texteXSD self.texteSimple = "" self.texteComplexe = "" self.nomDuTypePyxb='T_'+self.code @@ -350,7 +350,7 @@ class X_JDC_CATA : self.texteXSD += self.texteCata self.texteXSD += self.texteElt self.texteXSD += texteFin - if not PourTraduction : print (self.texteXSD) + #if not PourTraduction : print (self.texteXSD) dico = {} for k in list(cata.dictTypesXSD.keys()): if len(cata.dictTypesXSD[k]) > 1: @@ -364,6 +364,7 @@ class X_JDC_CATA : #import pprint #if (not PourTraduction) and (dico != {}) : pprint.pprint(dico) + return self.texteXSD def dumpDifferenceModuleMetier(self): @@ -387,7 +388,7 @@ class X_JDC_CATA : self.texteElt = "" for c in allClassToDump : - if (isinstance(c, Accas.ETAPE)) : print (c, 'aDumper') + if not(isinstance(c, Accas.OPER)) and not(isinstance(c, Accas.PROC)) : continue c.code=self.code c.dumpXsd(inExtension=True) self.texteSimple += c.texteSimple @@ -398,4 +399,5 @@ class X_JDC_CATA : #print (self.texteSimple) #print (self.texteElt) self.texteXSD = self.texteCata+'\n'+self.texteSimple+'\n'+self.texteElt+'\n'+texteFin+'\n' - if not PourTraduction : print (self.texteXSD) + #if not PourTraduction : print (self.texteXSD) + return self.texteXSD diff --git a/Efi2Xsd/MCAccasXsd.py b/Efi2Xsd/MCAccasXsd.py index f0471ed9..31682cde 100755 --- a/Efi2Xsd/MCAccasXsd.py +++ b/Efi2Xsd/MCAccasXsd.py @@ -44,7 +44,7 @@ class X_OBJECT: #print (listeArg) nvlObjPerePyxb=self.perePyxb.maClasseModeleMetier(*listeArg) #print (nvlObjPerePyxb) - print (nvlObjPerePyxb.orderedContent()) + #print (nvlObjPerePyxb.orderedContent()) self.perePyxb.objPyxb=nvlObjPerePyxb self.perePyxb.objPyxb.objAccas=ancienObjPerePyxb.objAccas @@ -450,13 +450,13 @@ class X_JDC (X_MCCOMPO): # print(e.details()) def toXml(self,fichier=None): - print ('ds to XML') + #print ('ds to XML') if not self.cata.modeleMetier : return #print ('***************',self.objPyxb,'***************',) #print ('***************',self,'***************',) #print ('***************',self.objPyxb.orderedContent(),'***************',) #print(self.objPyxb.toDOM().toprettyxml()) - print(self.objPyxb.toxml()) + #print(self.objPyxb.toxml()) return (self.objPyxb.toDOM().toprettyxml()) diff --git a/Ihm/I_JDC.py b/Ihm/I_JDC.py index 0d4887fd..880ed3d6 100644 --- a/Ihm/I_JDC.py +++ b/Ihm/I_JDC.py @@ -906,7 +906,6 @@ class JDC(I_OBJECT.OBJECT): # positionne prealablement par un appel a setEtapeContext if CONTEXT.debug : print(("JDC.NommerSdprod ",sd,sdnom)) - print(("JDC.NommerSdprod ",sd,sdnom)) if self._etape_context: o=self.getContexteAvant(self._etape_context).get(sdnom,None) diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index 9fa073cc..96be6965 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -37,10 +37,10 @@ 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) -def getEficasSsIhm(code=None,fichier=None,ssCode=None,multi=False,langue='en',versionCode=None): - #print (versionCode) +def getEficasSsIhm(code=None,fichier=None,ssCode=None,multi=False,langue='en',versionCode=None, fichierCata=None): + if fichierCata != None : fichierCata = os.path.abspath(fichierCata) from InterfaceQT4.qtEficasSsIhm import AppliSsIhm - Eficas=AppliSsIhm(code=code,salome=0,ssCode=ssCode,multi=multi,langue=langue,versionCode=versionCode) + Eficas=AppliSsIhm(code=code,salome=0,ssCode=ssCode,multi=multi,langue=langue,versionCode=versionCode, fichierCata=fichierCata) from Editeur import session options=session.parse(['ssIhm','-k',code,'-v',versionCode]) return Eficas @@ -77,6 +77,23 @@ def lanceEficas(code=None,fichier=None,ssCode=None,multi=False,langue='en'): res=app.exec_() sys.exit(res) +def genereXSD(code=None,fichier=None,ssCode=None,multi=False,langue='en',debug=True): + from Editeur import session + options=session.parse(sys.argv) + if options.code!= None : code=options.code + if options.ssCode!= None : ssCode=options.ssCode + if options.cata == None : + print ('Use -c cata_name.py') + return + monEficasSsIhm = getEficasSsIhm(code=code, fichierCata=options.cata) + monEditor=monEficasSsIhm.getEditor() + texteXSD=monEficasSsIhm.dumpXsd() + + fileXSD = options.cata[:options.cata.rfind(".")] + '_genere.xsd' + f = open( str(fileXSD), 'w') + f.write(str(texteXSD)) + + def lanceEficas_ssIhm(code=None,fichier=None,ssCode=None,version=None,debug=False,langue='en'): """ diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index 0feaff47..05b8db93 100755 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -48,7 +48,7 @@ class Appli(AppliSsIhm,Ui_Eficas,QMainWindow): """ Class implementing the main user interface. """ - def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False,versionCode=None): + def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=False,versionCode=None,fichierCata=None): """ Constructor """ @@ -56,7 +56,7 @@ class Appli(AppliSsIhm,Ui_Eficas,QMainWindow): print ('mauvaise utilisation de la classe Appli. Utiliser AppliSsIm SVP') exit() - AppliSsIhm.__init__(self,code,salome,parent,ssCode,multi,langue,ssIhm=True,versionCode=None) + AppliSsIhm.__init__(self,code,salome,parent,ssCode,multi,langue,ssIhm=True,versionCode=versionCode,fichierCata=fichierCata) QMainWindow.__init__(self,parent) Ui_Eficas.__init__(self) diff --git a/InterfaceQT4/qtEficasSsIhm.py b/InterfaceQT4/qtEficasSsIhm.py index 963c678d..df16af25 100755 --- a/InterfaceQT4/qtEficasSsIhm.py +++ b/InterfaceQT4/qtEficasSsIhm.py @@ -38,13 +38,14 @@ class AppliSsIhm: """ Class implementing the main user interface. """ - def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=True,versionCode=None): + def __init__(self,code=None,salome=1,parent=None,ssCode=None,multi=False,langue='fr',ssIhm=True,versionCode=None,fichierCata=None): """ Constructor """ version=getEficasVersion() self.VERSION_EFICAS="Eficas QT5 Salome " + version self.versionCode=versionCode + self.fichierCata=fichierCata self.salome=salome self.ssIhm=True @@ -129,16 +130,26 @@ class AppliSsIhm: def initEditor(self,fichier = None,jdc = None, units = None,include=0): - if self.editor != None : + if (hasattr(self, 'editor')) and self.editor != None : print ('un seul editeur par appli') sys.Exit() - self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include) + #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include) + self.editor = self.viewmanager.getNewEditorNormal() + + def initEditorNormal(self,fichier = None,jdc = None, units = None,include=0): + if (hasattr(self, 'editor')) and self.editor != None : + print ('un seul editeur par appli') + sys.Exit() + #self.editor = JDCEditorSsIhm(self,fichier, jdc, self.myQtab,units=units,include=include) + self.editor = self.viewmanager.getNewEditorNormal() def fileNew(self): - self.editor=initEditor(self) + self.editor=self.initEditor() def getEditor(self): + if (hasattr(self, 'editor')) and self.editor != None : return self.editor + self.initEditor() return self.editor def fileOpen(self,fichier): @@ -162,8 +173,10 @@ class AppliSsIhm: def dumpXsd(self): current_cata = CONTEXT.getCurrentCata() - current_cata.dumpXsd() - if self.maConfiguration.afficheIhm==False : exit() + texteXSD = current_cata.dumpXsd() + return texteXSD + #if self.maConfiguration.afficheIhm==False : exit() + #else : return texteXSD #,self.fileSaveAs #,self.fileClose diff --git a/InterfaceQT4/readercata.py b/InterfaceQT4/readercata.py index 37c43124..9f7ab761 100644 --- a/InterfaceQT4/readercata.py +++ b/InterfaceQT4/readercata.py @@ -108,7 +108,13 @@ class ReaderCataCommun(object): if self.ssCode is None: liste_cata_possibles = all_cata_list else: for catalogue in all_cata_list: - if catalogue.code == self.code and catalogue.file_format == self.ssCode: liste_cata_possibles.append(catalogue) + if catalogue.code == self.code and catalogue.file_format == self.ssCode: liste_cata_possibles.append(catalogue) + if self.appliEficas.fichierCata != None : + for catalogue in all_cata_list: + if os.path.abspath(catalogue.cata_file_path) == self.appliEficas.fichierCata : + liste_cata_possibles=(catalogue,) + break + if len(liste_cata_possibles)==0: try : @@ -155,6 +161,9 @@ class ReaderCataCommun(object): else: # plusieurs catalogues sont disponibles : il faut demander a l'utilisateur # lequel il veut utiliser ... + if self.appliEficas.ssIhm : + print ('Unable to know which catafile is choosen') + exit() self.askChoixCatalogue(cata_choice_list) self.demandeCatalogue=True diff --git a/InterfaceQT4/viewManagerSsIhm.py b/InterfaceQT4/viewManagerSsIhm.py index 82eba4c8..93af86e2 100644 --- a/InterfaceQT4/viewManagerSsIhm.py +++ b/InterfaceQT4/viewManagerSsIhm.py @@ -123,6 +123,15 @@ class MyViewManagerSsIhm(object): print ('impossible de construire le jdc') return None +# -------------------------------------------------------------------------------- + def getNewEditorNormal(self,fichier = None,jdc = None, units = None,include=0): +# -------------------------------------------------------------------------------- + + from InterfaceQT4.editorSsIhm import JDCEditorSsIhm + editor = JDCEditorSsIhm(self.appliEficas,fichier,jdc, units=units,include=include) + self.editor=editor + return editor + # ----------------------------- def samePath(self,f1, f2): # ------------------------------ diff --git a/Vimmp/generateXSD.py b/Vimmp/generateXSD.py new file mode 100755 index 00000000..ed550619 --- /dev/null +++ b/Vimmp/generateXSD.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 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 a lancer EFICAS configure pour Meteo +""" +# Modules Python +# Modules Eficas +import prefs +name='prefs_'+prefs.code +__import__(name) + +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../..')) + +import prefs +from InterfaceQT4 import eficas_go +eficas_go.genereXSD(code=prefs.code) diff --git a/generator/generator_XML.py b/generator/generator_XML.py index 1afd5463..b6f9c9d0 100644 --- a/generator/generator_XML.py +++ b/generator/generator_XML.py @@ -57,7 +57,6 @@ class XMLGenerator(PythonGenerator): def gener(self,obj,format='brut',config=None,appli=None): try : - print (obj) self.texteXML=obj.toXml() except : self.texteXML='erreur generation' @@ -78,7 +77,7 @@ class XMLGenerator(PythonGenerator): def writeDefault(self,fn) : fileXML = fn[:fn.rfind(".")] + '.xml' #fileDico='/tmp/toto.xml' - print (self.texteXML) + #print (self.texteXML) f = open( str(fileXML), 'w') f.write(str(self.texteXML)) f.close()