options.comm.append(file)
options.studies.append({"comm":file})
#print options.studies
- elif len(args)==1 and (re.search('.comm',file) or re.search('.map',file) or re.search('.cas',file)):
+ elif len(args)==1 and (re.search('.comm',file) or re.search('.map',file) or re.search('.cas',file) or re.search('.xml',file)):
try :
f=open(file,'w')
f.close()
self.tree.racine.item.getObject().nom=os.path.basename(newName)
self.tree.racine.updateNodeLabel()
- if self.jdc.cata.modeleMetier : self.jdc.toXml(self.fichier)
+
+ if self.jdc.cata.modeleMetier:self.jdc.toXml(self.fichier)
+ if self.jdc.cata.modeleMetier and self.jdc.isValid():
+ if self.generator != self.XMLgenerator :
+ self.XMLgenerator.gener(self.jdc)
+ self.XMLgenerator.writeDefault(fn)
if self.jdc.isValid() != 0 and hasattr(self.generator, "writeDefault"):
#if hasattr(self.generator, "writeDefault"):
if debug : print ('dans le init de JDCEditorSsIhm')
self.appliEficas = appliEficas
self.fichier = fichier
- self.fichierComplet = fichier
+ self.fichierComplet = fichier
+ self.extensionFichier = os.path.splitext(fichier)[1]
self.jdc = jdc
self.first = True
self.jdc_item = None
self.maConfiguration.mesGenerators = generator
self.maConfiguration.mesconvertisseurs = convert
- try :
- self.XMLGenerateur=generator.plugins['xml']()
- except :
- self.XMLGenerateur=None
+ try : self.XMLReader=convert.plugins['xml']()
+ except : self.XMLReader=None
+ try : self.XMLgenerator=generator.plugins['xml']()
+ except : self.XMLgenerator=None
+
if self.formatFichierOut in generator.plugins.keys():
self.generator = generator.plugins[self.formatFichierOut]()
except :
print ("mauvaise lecture du fichier")
if self.salome :
- try :
- self.appliEficas.addJdcInSalome( self.fichier)
- except :
- print ("mauvais enregistrement dans Salome")
+ try : self.appliEficas.addJdcInSalome( self.fichier)
+ except : print ("mauvais enregistrement dans Salome")
else :
self.jdc=jdc
else:
if not self.jdc: # nouveau jdc
- if not include :
- self.jdc = self._newJDC(units=units)
- else :
- self.jdc = self._newJDCInclude(units=units)
+ if not include : self.jdc = self._newJDC(units=units)
+ else : self.jdc = self._newJDCInclude(units=units)
self.nouveau=1
if self.jdc:
self.jdc.lang = self.appliEficas.langue
self.jdc.aReafficher=False
txt_exception = None
- if not jdc:
- self.jdc.analyse()
+ if not jdc:
+ if self.extensionFichier == '.xml' :
+ if self.appliEficas.maConfiguration.withXSD: self.jdc.analyseXML()
+ else : print ('run MDM with -x option (MDM for XML)'); exit()
+ else : self.jdc.analyse()
txt_exception = self.jdc.cr.getMessException()
if txt_exception :
self.jdc = None
"""
+ if self.jdc.cata.modeleMetier and self.jdc.isValid():
+ if self.generator != self.XMLgenerator :
+ self.XMLgenerator.gener(self.jdc)
+ self.XMLgenerator.writeDefault(fichier)
if not (self.writeFile(fichier,formatLigne=formatLigne)): return (0, None)
self.fichierOut = fichier
monEditeur.XMLGenerateur.gener(monEditeur.jdc)
monEditeur.XMLGenerateur.writeDefault(fichierXML)
+def validateDataSet(code=None):
+#------------------------------
+ from Editeur import session
+ options=session.parse(sys.argv)
+ if code != None : options.code = code
+ if options.fichierCata == None :
+ print ('Use -c cata_name.py')
+ return
+ fichier=options.comm[0]
+ if fichier==None :
+ print ('comm file is needed')
+ return
+ from .editorSsIhm import JDCEditorSsIhm
+ monEficasSsIhm = getEficasSsIhm(code=options.code)
+ monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier)
+ if not (monEditeur.jdc.isValid()) : print (monEditeur.getJdcRapport())
+ else : print ('Jdc is valid')
+ return monEditeur.jdc.isValid()
+
+
# --------------------------- toutes les fonctions après sont obseletes
if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
from Extensions import localisation
localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
+ if self.withXSD : self.maConfiguration.withXSD=True
def getSource(self,file):
--- /dev/null
+#!/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
+#
+"""
+""
+ cree le .xml associe au .comm
+ generateXML.py -c leCatalogue le.comm
+ 23 avril
+
+"""
+# Modules Python
+# Modules Eficas
+
+import sys
+import os
+sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../'))
+
+from InterfaceQT4 import eficas_go
+eficas_go.validateDataSet(code='NonConnu')
MDM is designed to help code developpers. It allows to:
- * simplify the writing of data models and have both a description in the MDM grammar end a corresponding unambiguous XSD description
- * validate datasets against these data models
- * automatically generate XML drivers (in C++ and Python) for input/output parameters.
- * automatically generate an GUI which allows end users to write a specific code parameter file in xml or python format. This GUI frees the user from syntax and semantic issues and guarantees data integrity
- * provide help to define the calculation scheme in Salome environment.
+ * simplify the writing of data models thanks to MDM definition specific langage (DSL) in python.
+ * automatically generate a corresponding unambiguous XSD description.
+ * offer dynamic validation which allows to take into account the value of certain parameters to activate specific parts of the model.
+ * maintain consistency between the version of the model expressed in the MDM grammar and the corresponding XSD version.
+ * validate datasets against these data models (one of them or both)
+ * use directly the produced XSDs (thanks to their unambiguity) in automatic driver generation tools (such as pyxb) and thus easely generate XML drivers (in C++ and Python) for input/output parameters.
+ * automatically generate an GUI which allows end users to write a specific code parameter file / dataset in xml or python format. This GUI frees the user from syntax and semantic issues and guarantees data integrity
+ * provide help to define the calculation scheme / calculation workflows in Salome environment.
-
-MDM format is XML Schema Definition (XSD).
The dataset format is either python or XML, or both.
-A valid dataset conforms to the structure and the rules of the data model.
-MDM is python code. For Gui Part, QT5 is needed.
+A valid dataset conforms to the structure and the rules of the data model against both XSD and DSL python format.
+MDM is developped in python. For Gui Part, QT5 is needed.
General Behaviour
_________________
* Models
Most automatic driver generation tools require an XSD definition of the data model. However, writing a data model directly into XSD is often painful and time consuming.
- the MDM grammar is used to express a data model faster in a python-like format (called catalog). MDM provides an .xsd mapping and Translation from this grammar to XSD is done automatically. Resulting XSD are unambiguous and can also be used easely with automatic drivers generating tools. MDM allows to manages dynamic validation rules (a simple way to activate part of the XSD description according to the values of certain parameters,). It also provides a graphical (model-compliant) interface to create valid sets of documents / user data.
+ the MDM grammar is used to express a data model faster in a python-like format (called catalog). MDM provides an .xsd mapping able to transcribe level of validation made in MDM. Translation from this grammar to XSD is done automatically. Resulting XSD are unambiguous and can also be used easely with automatic drivers generating tools. MDM allows to manages dynamic validation rules (a simple way to activate part of the XSD description according to the values of certain parameters,). It also provides a graphical (model-compliant) interface to create valid sets of documents / user data. In addition, this generated graphical representation allows a virtuous cycle between the design of the model and the visual representation.
An MDM catalog can contain other MDM catalogs. This means that others catalogs can be used to supplement the structure of another catalog through inclusion/import mechanisms.
* Data Sets
The available commands are defined in the data model.
- In order to create a new valid data set, the end user can use the GUI and choose commands (parts of the XSD schema) from those available. He defines valid values for mandatory parameters (cardinality, type...) and adds optional parameters if necessary.
+ In order to create a new valid data set, the end user can use the GUI and choose parameters/commands (parts of the XSD schema) from those available. He defines valid values for mandatory parameters (cardinality, type...) and adds optional parameters if necessary.
Data sets can be built/modified/validated by command line (TUI).
- The python/dataset duality in XML allows the dataset to be executed in a proper python context, in addition to being able to be used as a set of input parameters for code.
+refaire la phrase
+ The python/XML duality of the dataset expression allows on the one hand to execute the dataset in a proper python context, and/or, on the other hand to use it as a set of input parameters for code.
* Workflows
Workflows managed by an orchestrator such as the YACS module of the SALOME project manipulate the parameters to launch codes.