1 # -*- coding: iso-8859-1 -*-
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
22 #from ExtractGeneratorandLoadList import ExtractGeneratorandLoadList
23 from ExtractGeneratorandLoadList import ExtractGeneratorandLoadList2
25 def INCLUDE(self,chemin_psse,fichier_sav,**args):
27 Fonction sd_prod pour la macro INCLUDE
32 if hasattr(self,'fichier_ini'):
34 if self.fichier_ini == fichier_sav : return
35 if hasattr(self,'old_context_fichier_init' ):
36 for concept in self.old_context_fichier_init.values():
37 self.jdc.delete_concept(concept)
39 self.contexte_fichier_init={}
40 self.reevalue_sd_jdc()
41 self.jdc.reset_context()
43 self.fichier_ini=fichier_sav
44 self.contexte_fichier_init = {}
45 self.fichier_unite = 999
46 self.fichier_err = None
51 pattern_debut_ligne = re.compile(r'^[0-9].*')
53 MachineListOrigin,LoadListOrigin= ExtractGeneratorandLoadList2(fichier_sav,chemin_psse)
55 if self.jdc.appli is not None:
56 self.jdc.appli.affiche_alerte("Error", 'An error happened in ExtractGeneratorandLoadList execution ')
60 self.fichier_err = str(exc)
61 self.contexte_fichier_init = {}
66 for m in MachineListOrigin:
67 if m in LoadListOrigin : BusBarList.append(m)
68 else : MachineList.append(m)
70 for m in LoadListOrigin:
71 if m not in MachineListOrigin : LoadList.append(m)
74 nouv=m[0].replace(' ','_')
75 nouveau=nouv.replace('.','_')
76 nom = nouveau+"__"+str(m[1])
77 if pattern_debut_ligne.match(nom): nom='_'+nom
79 self.fichier_text += "%s=MONGENER(ID='%s',);\n" % (nom, id)
82 nouv=m[0].replace(' ','_')
83 nouveau=nouv.replace('.','_')
84 nom = nouveau+"__"+str(m[1])
85 if pattern_debut_ligne.match(nom): nom='_'+nom
87 self.fichier_text += "%s=MONBUSBAR(ID='%s',);\n" % (nom, id)
90 nouv=m[0].replace(' ','_')
91 nouveau=nouv.replace('.','_')
92 nom = nouveau+"__"+str(m[1])
93 if pattern_debut_ligne.match(nom): nom='_'+nom
94 if pattern_debut_ligne.match(nom): print 'match'
96 self.fichier_text += "%s=MACHARGE(ID='%s',);\n" % (nom, id)
98 import Extensions.jdc_include
99 self.JdC_aux = Extensions.jdc_include.JDC_CATA_INCLUDE(code='PSEN', execmodul=None)
100 self.make_contexte_include(None, self.fichier_text)
101 self.old_context_fichier_init = self.contexte_fichier_init
102 self.parent.record_unit(unite, self)
105 def INCLUDE_context(self,d):
107 Fonction op_init pour macro INCLUDE
109 for k,v in self.g_context.items():