1 #@ MODIF N_SIMP Noyau DATE 27/03/2002 AUTEUR DURAND C.DURAND
2 # CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
20 # ======================================================================
21 """ Ce module contient la classe de definition SIMP
22 qui permet de spécifier les caractéristiques des mots clés simples
30 class SIMP(N_ENTITE.ENTITE):
32 Classe pour definir un mot cle simple
34 Cette classe a deux attributs de classe
36 - class_instance qui indique la classe qui devra etre utilisée
37 pour créer l'objet qui servira à controler la conformité d'un
38 mot-clé simple avec sa définition
40 - label qui indique la nature de l'objet de définition (ici, SIMP)
43 class_instance = N_MCSIMP.MCSIMP
46 def __init__(self,typ,fr="",ang="",statut='f',into=None,defaut=None,
47 min=1,max=1,homo=1,position ='local',
48 val_min = '**',val_max='**',docu=""):
51 Un mot-clé simple est caractérisé par les attributs suivants :
53 - type : cet attribut est obligatoire et indique le type de valeur attendue
79 N_ENTITE.ENTITE.__init__(self)
80 # Initialisation des attributs
81 if type(typ) == types.TupleType :
93 self.position = position
100 Cette methode sert à valider les attributs de l'objet de définition
103 if type(self.min) != types.IntType :
105 self.cr.fatal("L'attribut 'min' doit etre un entier : "+`self.min`)
106 if type(self.max) != types.IntType :
107 if self.max != '**' :
108 self.cr.fatal("L'attribut 'max' doit etre un entier : "+`self.max`)
109 if self.min > self.max :
110 self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`))
111 if type(self.fr) != types.StringType :
112 self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" +`self.fr`)
113 if self.statut not in ['o','f','c','d']:
114 self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`)
115 if self.homo != 0 and self.homo != 1 :
116 self.cr.fatal("L'attribut 'homo' doit valoir 0 ou 1 : %s" %`self.homo`)
117 if self.into != None :
118 if type(self.into) != types.TupleType :
119 self.cr.fatal("L'attribut 'into' doit etre un tuple : %s" %`self.into`)
120 if self.position not in ['local','global','global_jdc']:
121 self.cr.fatal("L'attribut 'position' doit valoir 'local','global' ou 'global_jdc' : %s" %`self.position`)
124 def __call__(self,val,nom,parent=None):
126 Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
127 de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
129 return self.class_instance(nom=nom,definition=self,val=val,parent=parent)