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.
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.
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.
22 # ======================================================================
25 """ Ce module contient la classe de definition SIMP
26 qui permet de spécifier les caractéristiques des mots clés simples
34 class SIMP(N_ENTITE.ENTITE):
36 Classe pour definir un mot cle simple
38 Cette classe a deux attributs de classe
40 - class_instance qui indique la classe qui devra etre utilisée
41 pour créer l'objet qui servira à controler la conformité d'un
42 mot-clé simple avec sa définition
44 - label qui indique la nature de l'objet de définition (ici, SIMP)
47 class_instance = N_MCSIMP.MCSIMP
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):
55 Un mot-clé simple est caractérisé par les attributs suivants :
57 - type : cet attribut est obligatoire et indique le type de valeur attendue
83 N_ENTITE.ENTITE.__init__(self,validators)
84 # Initialisation des attributs
85 if type(typ) == types.TupleType :
97 self.position = position
102 def verif_cata(self):
104 Cette methode sert à valider les attributs de l'objet de définition
107 if type(self.min) != types.IntType :
109 self.cr.fatal("L'attribut 'min' doit etre un entier : "+`self.min`)
110 if type(self.max) != types.IntType :
111 if self.max != '**' :
112 self.cr.fatal("L'attribut 'max' doit etre un entier : "+`self.max`)
113 if self.min > self.max :
114 self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`))
115 if type(self.fr) != types.StringType :
116 self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" +`self.fr`)
117 if self.statut not in ['o','f','c','d']:
118 self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`)
119 if self.homo != 0 and self.homo != 1 :
120 self.cr.fatal("L'attribut 'homo' doit valoir 0 ou 1 : %s" %`self.homo`)
121 if self.into != None :
122 if type(self.into) != types.TupleType :
123 self.cr.fatal("L'attribut 'into' doit etre un tuple : %s" %`self.into`)
124 if self.position not in ['local','global','global_jdc']:
125 self.cr.fatal("L'attribut 'position' doit valoir 'local','global' ou 'global_jdc' : %s" %`self.position`)
126 if self.validators and not self.validators.verif_cata():
127 self.cr.fatal("Un des validateurs est incorrect. Raison : "+self.validators.cata_info)
129 def __call__(self,val,nom,parent=None):
131 Construit un objet mot cle simple (MCSIMP) a partir de sa definition (self)
132 de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
134 return self.class_instance(nom=nom,definition=self,val=val,parent=parent)