1 # -*- coding: utf-8 -*-
2 # CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
20 # ======================================================================
22 Ce module contient le plugin generateur de fichier au format
27 import types,string,re,os
29 from generator_python import PythonGenerator
33 Retourne les informations necessaires pour le chargeur de plugins
35 Ces informations sont retournees dans un dictionnaire
40 # La factory pour creer une instance du plugin
41 'factory' : SEPGenerator,
45 class SEPGenerator(PythonGenerator):
47 Ce generateur parcourt un objet de type JDC et produit
48 un texte au format eficas et
52 # Les extensions de fichier permis?
55 def gener(self,obj,format='brut',config=None):
57 # Cette instruction génère le contenu du fichier de commandes (persistance)
58 self.text=PythonGenerator.gener(self,obj,format)
59 # Cette instruction génère le contenu du fichier de paramètres python
64 return self.texteTubePy
68 Prépare le contenu du fichier de paramètres python. Le contenu
69 peut ensuite être obtenu au moyen de la fonction getTubePy().
71 #self.__genereSEP_withVariables()
72 self.__genereSEP_withDico()
74 def __genereSEP_withVariables(self) :
76 Les paramètres sont transcrits sous forme de variables nom=valeur.
78 self.texteTubePy="# Parametres generes par Eficas \n"
79 for MC in self.dictMCVal.keys():
80 ligne = MC +"="+ repr(self.dictMCVal[MC])+'\n'
81 self.texteTubePy=self.texteTubePy+ligne
83 print self.texteTubePy
85 # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin)
86 fichier=os.path.join(os.path.dirname(__file__),"tube.py")
88 for ligne in f.readlines():
89 self.texteTubePy=self.texteTubePy+ligne
92 def __genereSEP_withDico(self) :
94 Les paramètres sont transcrits sous la forme d'un dictionnaire nom=valeur.
96 from Sep import properties
97 self.texteTubePy="# -*- coding: utf-8 -*-\n"
98 self.texteTubePy+="# ======================================================================================\n"
99 self.texteTubePy+="# FICHIER GENERE PAR EFICAS - OUTIL MÉTIER SOUS-EPAISSEUR - "
100 self.texteTubePy+="VERSION "+str(properties.version)+" du "+str(properties.date)+"\n"
101 self.texteTubePy+="# ======================================================================================\n"
102 self.texteTubePy+="\n"
103 self.texteTubePy+="# Parametres Utilisateur Eficas \n"
104 self.texteTubePy+="parameters={}\n"
106 for MC in self.dictMCVal.keys():
107 ligne = "parameters['"+MC+"']="+ repr(self.dictMCVal[MC])+'\n'
108 self.texteTubePy=self.texteTubePy+ligne
110 # On ajoute des paramètres de configuration pour contrôle de
111 # cohérence avec la procédure outil métier
112 self.texteTubePy+="# Parametres de Configuration Eficas \n"
113 ligne = "parameters['OMVERSION']="+str(properties.version)+"\n"
114 self.texteTubePy+=ligne
116 # __GBO__: Tester self.tube pour aiguiller en fonction du cas (au besoin)
117 self.texteTubePy+="\n"
118 self.texteTubePy+="# Exécution de la procédure outil métier \n"
119 self.texteTubePy+="import os,sys\n"
120 self.texteTubePy+="sys.path.insert(0,os.environ['OM_ROOT_DIR'])\n"
121 self.texteTubePy+="import om_data\n"
122 self.texteTubePy+="om_data.setParameters(parameters)\n"
123 self.texteTubePy+="def run():\n"
124 self.texteTubePy+=" import om_smeca\n"
125 self.texteTubePy+="\n"
126 self.texteTubePy+='if __name__ == "__main__":\n'
127 self.texteTubePy+=" run()\n"
130 print self.texteTubePy
139 # __GBO__: surcharge de PythonGenerator:
140 # voir example generator_cuve2dg.py (genea)
141 def generMCSIMP(self,obj) :
143 Convertit un objet MCSIMP en texte python
144 Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable
147 for i in obj.get_genealogie() :
149 #self.dictMCVal[obj.nom]=obj.valeur
150 self.dictMCVal[clef]=obj.valeur
152 s=PythonGenerator.generMCSIMP(self,obj)
155 # __GBO__: surcharge de PythonGenerator
156 def generMACRO_ETAPE(self,obj):
158 if obj.nom == "S_EP_INTERNE" :
160 if obj.nom == "M_COUDE" :
162 s=PythonGenerator.generMACRO_ETAPE(self,obj)