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 utilisee
41 pour creer l'objet qui servira a controler la conformite d'un
42 mot-cle 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-cle simple est caracterise par les attributs suivants :
57 - type : cet attribut est obligatoire et indique le type de valeur attendue
71 N_ENTITE.ENTITE.__init__(self,validators)
72 # Initialisation des attributs
73 if type(typ) == types.TupleType :
85 self.position = position
92 Cette methode sert a valider les attributs de l'objet de definition
95 if type(self.min) != types.IntType :
97 self.cr.fatal("L'attribut 'min' doit etre un entier : "+`self.min`)
98 if type(self.max) != types.IntType :
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)
117 def __call__(self,val,nom,parent=None):
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)
122 return self.class_instance(nom=nom,definition=self,val=val,parent=parent)