Salome HOME
travail sur monPlusieurs
[tools/eficas.git] / Noyau / N_SIMP.py
1 # -*- coding: iso-8859-1 -*-
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 la classe de definition SIMP
22     qui permet de spécifier les caractéristiques des mots clés simples
23 """
24
25 import types
26
27 import N_ENTITE
28 import N_MCSIMP
29 from strfunc import ufmt
30
31 class SIMP(N_ENTITE.ENTITE):
32    """
33     Classe pour definir un mot cle simple
34
35     Cette classe a deux attributs de classe
36
37     - class_instance qui indique la classe qui devra etre utilisée
38             pour créer l'objet qui servira à controler la conformité d'un
39             mot-clé simple avec sa définition
40
41     - label qui indique la nature de l'objet de définition (ici, SIMP)
42
43    """
44    class_instance = N_MCSIMP.MCSIMP
45    label = 'SIMP'
46
47    def __init__(self,typ,fr="",ang="",statut='f',into=None,defaut=None,
48                      min=1,max=1,homo=1,position ='local',
49                      val_min = '**',val_max='**',docu="",validators=None,sug=None):
50
51       """
52           Un mot-clé simple est caractérisé par les attributs suivants :
53
54           - type : cet attribut est obligatoire et indique le type de valeur attendue
55
56           - fr   :
57
58           - ang :
59
60           - statut :
61
62           - into   :
63
64           - defaut :
65
66           - min
67
68           - max
69
70           - homo
71
72           - position
73
74           - val_min
75
76           - val_max
77
78           - docu
79       """
80       N_ENTITE.ENTITE.__init__(self,validators)
81       # Initialisation des attributs
82       if type(typ) == types.TupleType :
83           self.type=typ
84       else :
85           self.type=(typ,)
86       self.fr=fr
87       self.ang=ang
88       self.statut=statut
89       self.into=into
90       self.defaut=defaut
91       self.min=min
92       self.max=max
93       self.homo=homo
94       self.position = position
95       self.val_min=val_min
96       self.val_max=val_max
97       self.docu = docu
98       self.sug = sug
99
100    def verif_cata(self):
101       """
102           Cette methode sert à valider les attributs de l'objet de définition
103           de la classe SIMP
104       """
105       self.check_min_max()
106       self.check_fr()
107       self.check_statut()
108       self.check_homo()
109       self.check_into()
110       self.check_position()
111       self.check_validators()
112
113    def __call__(self,val,nom,parent=None):
114       """
115           Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
116           de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
117       """
118       return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
119
120
121
122
123
124