Salome HOME
Pour Telemac et qques bugs
[tools/eficas.git] / generator / generator_GroupMA.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """
21     Ce module contient le plugin generateur d une liste des GroupNo et GroupMA
22 """
23 import traceback
24 import types,string,re
25
26 from generator_python import PythonGenerator
27 def entryPoint():
28    """
29        Retourne les informations nécessaires pour le chargeur de plugins
30
31        Ces informations sont retournées dans un dictionnaire
32    """
33    return {
34         # Le nom du plugin
35           'name' : 'GroupMA',
36         # La factory pour créer une instance du plugin
37           'factory' : GroupMAGenerator,
38           }
39
40
41 class GroupMAGenerator(PythonGenerator):
42    """
43        Ce generateur parcourt un objet de type JDC et produit
44        un texte au format eficas et 
45        un texte au format homard 
46
47    """
48    # Les extensions de fichier préconisées
49    extensions=('.comm',)
50
51    def __init__(self):
52       PythonGenerator.__init__(self)
53       self.listeMA=[]
54       self.listeNO=[]
55
56    def gener(self,obj,format='brut',config=None):
57       self.liste=[]
58       self.text=PythonGenerator.gener(self,obj,'brut',config=None)
59       return self.listeMA,self.listeNO
60
61    def generMCSIMP(self,obj) :
62        if 'grma' in repr(obj.definition.type) :
63           if not type(obj.valeur) in (list, tuple):
64              aTraiter=(obj.valeur,)
65           else :
66              aTraiter=obj.valeur
67           for group in aTraiter :
68              if group not in self.listeMA :
69                 self.listeMA.append(group)
70        if 'grno' in repr(obj.definition.type) :
71           if not type(obj.valeur) in (list, tuple):
72              aTraiter=(obj.valeur,)
73           else :
74              aTraiter=obj.valeur
75           for group in aTraiter :
76              if group not in self.listeNO :
77                 self.listeNO.append(group)
78        s=PythonGenerator.generMCSIMP(self,obj)
79        return s