1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 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
21 Ce module contient le plugin generateur de fichier au format
26 import types,string,re,os
27 from Extensions.i18n import tr
28 from generator_python import PythonGenerator
36 Retourne les informations necessaires pour le chargeur de plugins
38 Ces informations sont retournees dans un dictionnaire
43 # La factory pour creer une instance du plugin
44 'factory' : CreationGenerator,
48 class CreationGenerator(PythonGenerator):
52 # Les extensions de fichier permis?
54 def gener(self,obj,format='brut',config=None):
57 # Cette instruction genère le contenu du fichier de commandes (persistance)
58 self.text=PythonGenerator.gener(self,obj,format)
59 if obj.isvalid() : self.genereDescription()
63 def genereParam(self):
65 for monParam in self.dictParam.keys():
66 if self.dico.has_key(monParam) : continue
67 listeParam.append(self.dictParam[monParam])
69 if len(listeParam)== 0 : return
71 jdcDict=self.jdc.jdcDict
73 raise ValueError,tr("toutes les donnees ne sont pas connues")
74 for param in listeParam:
76 for etape in self.jdc.jdcDict.etapes:
77 if str(etape.sdnom) != str(param) :
83 raise ValueError,tr("toutes les donnees ne sont pas connues")
86 texteEtape=self.generETAPE(obj)
88 def genereDescription(self) :
94 def initDico(self,obj) :
99 self.jdc=obj.get_jdc_root()
101 self.texte_jdc_aux=self.jdc.recorded_units[999]
103 self.texte_jdc_aux=""
106 def generMCSIMP(self,obj) :
108 Convertit un objet MCSIMP en texte python
109 Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable
112 #print "MCSIMP", obj.nom, " ", obj.valeur
113 from cree_map_cata import param_map
114 if isinstance(obj.valeur,param_map):
115 self.dicoCourant[obj.nom]=obj.valeur.nom
116 self.dictParam[obj.valeur.nom]=obj.valeur
118 self.dicoCourant[obj.nom]=obj.valeur
119 s=PythonGenerator.generMCSIMP(self,obj)
122 def generPROC_ETAPE(self,obj):
124 s=PythonGenerator.generPROC_ETAPE(self,obj)
125 self.dico[obj.nom]=self.dicoCourant
128 def generETAPE(self,obj):
129 #print "ETAPE", obj.nom, " ",obj.sdnom
131 s=PythonGenerator.generETAPE(self,obj)
132 self.dico[obj.sdnom]=self.dicoCourant