Salome HOME
1er mise en coherence avec la 7_6
[tools/eficas.git] / Noyau / N_SIMP.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 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
32 class SIMP(N_ENTITE.ENTITE):
33
34     """
35      Classe pour definir un mot cle simple
36
37      Cette classe a deux attributs de classe
38
39      - class_instance qui indique la classe qui devra etre utilisée
40              pour créer l'objet qui servira à controler la conformité d'un
41              mot-clé simple avec sa définition
42
43      - label qui indique la nature de l'objet de définition (ici, SIMP)
44
45     """
46     class_instance = N_MCSIMP.MCSIMP
47     label = 'SIMP'
48
49     def __init__(self, typ,ang="", fr="", statut='f', into=None, defaut=None,
50                  min=1, max=1, homo=1, position='local',
51                  val_min='**', val_max='**', docu="", validators=None,
52                  sug=None):
53         """
54             Un mot-clé simple est caractérisé par les attributs suivants :
55             - type : cet attribut est obligatoire et indique le type de valeur attendue
56             - fr : chaîne documentaire en français
57             - statut : obligatoire ou facultatif ou caché
58             - into : valeurs autorisées
59             - defaut : valeur par défaut
60             - min : nombre minimal de valeurs
61             - max : nombre maximal de valeurs
62             - homo : ?
63             - ang : doc
64             - position : si global, le mot-clé peut-être lu n'importe où dans la commande
65             - val_min : valeur minimale autorisée
66             - val_max : valeur maximale autorisée
67             - docu : ?
68             - sug : ?
69         """
70         N_ENTITE.ENTITE.__init__(self, validators)
71         # Initialisation des attributs
72         if type(typ) == types.TupleType:
73             self.type = typ
74         else:
75             self.type = (typ,)
76         self.fr = fr
77         self.statut = statut
78         self.into = into
79         self.defaut = defaut
80         self.min = min
81         self.max = max
82         self.homo = homo
83         self.position = position
84         self.val_min = val_min
85         self.val_max = val_max
86         self.docu = docu
87         self.sug = sug
88         self.ang=ang
89
90     def verif_cata(self):
91         """
92             Cette methode sert à valider les attributs de l'objet de définition
93             de la classe SIMP
94         """
95         self.check_min_max()
96         self.check_fr()
97         self.check_statut()
98         self.check_homo()
99         self.check_into()
100         self.check_position()
101         self.check_validators()
102
103     def __call__(self, val, nom, parent=None):
104         """
105             Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
106             de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
107         """
108         return self.class_instance(nom=nom, definition=self, val=val, parent=parent)