Salome HOME
reindent + copyright + merge manuel avec la V9_dev sauf repertoires metier
[tools/eficas.git] / generator / generator_GroupMA.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021   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 from __future__ import absolute_import
24 import traceback
25 import types,re
26
27 from .generator_python import PythonGenerator
28 def entryPoint():
29     """
30         Retourne les informations necessaires pour le chargeur de plugins
31
32         Ces informations sont retournees dans un dictionnaire
33     """
34     return {
35          # Le nom du plugin
36            'name' : 'GroupMA',
37          # La factory pour creer une instance du plugin
38            'factory' : GroupMAGenerator,
39            }
40
41
42 class GroupMAGenerator(PythonGenerator):
43     """
44         Ce generateur parcourt un objet de type JDC et produit
45         un texte au format eficas et
46         un texte au format homard
47
48     """
49     # Les extensions de fichier preconisees
50     extensions=('.comm',)
51
52     def __init__(self):
53         PythonGenerator.__init__(self)
54         self.listeMA=[]
55         self.listeNO=[]
56
57     def gener(self,obj,format='brut',config=None):
58         self.liste=[]
59         self.text=PythonGenerator.gener(self,obj,'brut',config=None)
60         return self.listeMA,self.listeNO
61
62     def generMCSIMP(self,obj) :
63         if 'grma' in repr(obj.definition.type) :
64             if not type(obj.valeur) in (list, tuple):
65                 aTraiter=(obj.valeur,)
66             else :
67                 aTraiter=obj.valeur
68             for group in aTraiter :
69                 if group not in self.listeMA :
70                     self.listeMA.append(group)
71         if 'grno' in repr(obj.definition.type) :
72             if not type(obj.valeur) in (list, tuple):
73                 aTraiter=(obj.valeur,)
74             else :
75                 aTraiter=obj.valeur
76             for group in aTraiter :
77                 if group not in self.listeNO :
78                     self.listeNO.append(group)
79         s=PythonGenerator.generMCSIMP(self,obj)
80         return s