1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Ce module contient le plugin generateur de fichier au format Code_Carmel3D pour EFICAS.
23 from __future__ import absolute_import
24 from __future__ import print_function
26 from builtins import str
31 from Extensions.i18n import tr
32 from .generator_python import PythonGenerator
36 Retourne les informations necessaires pour le chargeur de plugins
37 Ces informations sont retournees dans un dictionnaire
42 # La factory pour creer une instance du plugin
43 'factory' : XMLGenerator,
47 class XMLGenerator(PythonGenerator):
49 Ce generateur parcourt un objet de type JDC et produit
50 un texte au format eficas et
53 # Les extensions de fichier permis?
56 #----------------------------------------------------------------------------------------
57 def gener(self,obj,format='brut',config=None,appliEficas=None):
59 print ('dans gener XMLGenerator Attention if 1 a la place de try ')
62 self.texteXML=obj.toXml()
64 # self.texteXML='erreur generation'
68 self.textePourAide =""
70 # Cette instruction genere le contenu du fichier de commandes (persistance)
71 self.text=PythonGenerator.gener(self,obj,format)
75 #----------------------------------------------------------------------------------------
77 #----------------------------------------------------------------------------------------
80 #----------------------------------------------------------------------------------------
82 def writeDefault(self,fn) :
83 fileXML = fn[:fn.rfind(".")] + '.xml'
84 #filePyxb = fn[:fn.rfind(".")] + '.py'
85 fileBase = os.path.basename(fileXML)
86 fileBase = fileBase[:fileBase.rfind(".")] + '.py'
87 filePyxb = '/tmp/' + fileBase
89 #fileDico='/tmp/toto.xml'
90 #print (self.texteXML)
91 f = open( str(fileXML), 'w')
92 f.write(str(self.texteXML))
95 f = open( str(filePyxb), 'w')
96 f.write(str(self.textePourAide))
100 def generMCSIMP(self,obj) :
101 if obj.nom in self.dictNbNomObj.keys():
102 nomUtil = obj.nom + "_" + str(self.dictNbNomObj[obj.nom])
103 self.dictNbNomObj[obj.nom] += 1
106 self.dictNbNomObj[obj.nom] = 1
107 self.textePourAide += nomUtil + " = vimmpCase." + obj.getNomDsXML() + "\n"
108 #self.textePourAide += "print '"+ nomUtil+ " =' , " + str(nomUtil) + "\n"
109 #self.textePourAide +='txt += "' + nomUtil + '" + " = " +str( ' + nomUtil + ') ' + "\n"
113 s=PythonGenerator.generMCSIMP(self,obj)