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
28 from Noyau import N_CR
29 from Noyau.N_utils import repr_float
30 from Accas import ETAPE,PROC_ETAPE,MACRO_ETAPE,ETAPE_NIVEAU,JDC,FORM_ETAPE
31 from Accas import MCSIMP,MCFACT,MCBLOC,MCList,EVAL
32 from Accas import GEOM,ASSD,MCNUPLET
33 from Accas import COMMENTAIRE,PARAMETRE, PARAMETRE_EVAL,COMMANDE_COMM
34 from Formatage import Formatage
36 import generator_python
40 Retourne les informations nécessaires pour le chargeur de plugins
42 Ces informations sont retournées dans un dictionnaire
47 # La factory pour créer une instance du plugin
48 'factory' : PythonGenerator,
52 class PythonGenerator(generator_python.PythonGenerator):
54 Ce generateur parcourt un objet de type JDC et produit
55 un fichier au format python6
57 L'acquisition et le parcours sont réalisés par la méthode
58 generator.gener(objet_jdc,format)
60 L'écriture du fichier au format python6 par appel de la méthode
61 generator.writefile(nom_fichier)
63 Ses caractéristiques principales sont exposées dans des attributs
65 - extensions : qui donne une liste d'extensions de fichier préconisées
68 # Les extensions de fichier préconisées
71 def generFORM_ETAPE(self,obj):
73 Méthode particulière pour les objets de type FORMULE
77 if nom == '' : nom = 'sansnom'
78 l.append(nom + ' = FORMULE(')
79 for v in obj.mc_liste:
80 text=self.generator(v)
81 l.append(v.nom+'='+text)
85 def gen_formule(self,obj):
87 Méthode particuliere aux objets de type FORMULE
93 sdname= self.generator(obj.sd)
97 label=sdname + ' = FORMULE('
99 for v in obj.mc_liste:
101 s= v.nom+':'+sdname+'('+v.valeur+')'