]> SALOME platform Git repositories - tools/eficas.git/blob - Noyau/N_SIMP.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Noyau / N_SIMP.py
1 #@ MODIF N_SIMP Noyau  DATE 07/09/2009   AUTEUR COURTOIS M.COURTOIS 
2 # -*- coding: iso-8859-1 -*-
3 # RESPONSABLE COURTOIS M.COURTOIS
4 #            CONFIGURATION MANAGEMENT OF EDF VERSION
5 # ======================================================================
6 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
7 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
8 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
9 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR   
10 # (AT YOUR OPTION) ANY LATER VERSION.                                 
11 #
12 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT 
13 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF          
14 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU    
15 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.                            
16 #
17 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE   
18 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,       
19 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.      
20 #                                                                       
21 #                                                                       
22 # ======================================================================
23
24
25 """ Ce module contient la classe de definition SIMP
26     qui permet de spécifier les caractéristiques des mots clés simples
27 """
28
29 import types
30
31 import N_ENTITE
32 import N_MCSIMP
33
34 class SIMP(N_ENTITE.ENTITE):
35    """
36     Classe pour definir un mot cle simple 
37
38     Cette classe a deux attributs de classe 
39
40     - class_instance qui indique la classe qui devra etre utilisee 
41             pour creer l'objet qui servira a controler la conformite d'un 
42             mot-cle simple avec sa définition
43
44     - label qui indique la nature de l'objet de définition (ici, SIMP)
45
46    """
47    class_instance = N_MCSIMP.MCSIMP
48    label = 'SIMP'
49
50    def __init__(self,typ,fr="",ang="",statut='f',into=None,defaut=None,
51                      min=1,max=1,homo=1,position ='local',
52                      val_min = '**',val_max='**',docu="",validators=None):
53      
54       """
55           Un mot-cle simple est caracterise par les attributs suivants :
56
57           - type : cet attribut est obligatoire et indique le type de valeur attendue 
58           - fr   :
59           - ang :
60           - statut :
61           - into   :
62           - defaut :
63           - min
64           - max
65           - homo
66           - position
67           - val_min
68           - val_max
69           - docu
70       """
71       N_ENTITE.ENTITE.__init__(self,validators)
72       # Initialisation des attributs
73       if type(typ) == types.TupleType :
74           self.type=typ
75       else :
76           self.type=(typ,)
77       self.fr=fr
78       self.ang=ang
79       self.statut=statut
80       self.into=into
81       self.defaut=defaut
82       self.min=min
83       self.max=max
84       self.homo=homo
85       self.position = position
86       self.val_min=val_min
87       self.val_max=val_max
88       self.docu = docu
89
90    def verif_cata(self):
91       """
92           Cette methode sert a valider les attributs de l'objet de definition 
93           de la classe SIMP
94       """
95       if type(self.min) != types.IntType :
96          if self.min != '**':
97             self.cr.fatal("L'attribut 'min' doit etre un entier : "+`self.min`)
98       if type(self.max) != types.IntType :
99          if self.max != '**' :
100             self.cr.fatal("L'attribut 'max' doit etre un entier : "+`self.max`)
101       if self.min > self.max :
102          self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`))
103       if type(self.fr) != types.StringType :
104          self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" +`self.fr`)
105       if self.statut not in ['o','f','c','d']:
106          self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`)
107       if self.homo != 0 and self.homo != 1 :
108          self.cr.fatal("L'attribut 'homo' doit valoir 0 ou 1 : %s" %`self.homo`)
109       if self.into != None :
110          if type(self.into) != types.TupleType :
111             self.cr.fatal("L'attribut 'into' doit etre un tuple : %s" %`self.into`)
112       if self.position not in ['local','global','global_jdc']:
113          self.cr.fatal("L'attribut 'position' doit valoir 'local','global' ou 'global_jdc' : %s" %`self.position`)
114       if self.validators and not self.validators.verif_cata():
115          self.cr.fatal("Un des validateurs est incorrect. Raison : "+self.validators.cata_info)
116
117    def __call__(self,val,nom,parent=None):
118       """
119           Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
120           de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
121       """
122       return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
123
124