1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Ce module contient la classe de définition pour les nuplets NUPL
27 from Noyau import N_ENTITE,N_MCLIST,N_CR
28 from Ihm import I_ENTITE
29 from Extensions.i18n import tr
32 class NUPL(N_ENTITE.ENTITE,I_ENTITE.ENTITE):
35 class_instance = mcnuplet.MCNUPLET
36 list_instance = N_MCLIST.MCList
40 def __init__(self,fr="",ang="",docu="",statut='f',defaut=None,min=0,max=1,
42 N_ENTITE.ENTITE.__init__(self)
43 I_ENTITE.ENTITE.__init__(self)
53 # on force le statut des sous entites a obligatoire
54 for e in elements:e.statut='o'
55 self.idracine="NUPLET"
56 self.affecter_parente()
60 Cette methode sert à valider les attributs de l'objet de définition
63 if type(self.min) != types.IntType :
65 self.cr.fatal(tr("L'attribut 'min' doit etre un entier : ")+str(self.min))
66 if type(self.max) != types.IntType :
68 self.cr.fatal(tr("L'attribut 'max' doit etre un entier : ")+str(self.max))
69 if self.min > self.max :
70 self.cr.fatal(tr("Nombres d'occurrence min et max invalides :") +str(self.min)+","+str(self.max))
71 if type(self.fr) != types.StringType :
72 self.cr.fatal(tr("L'attribut 'fr' doit etre une chaine de caracteres"))
73 if self.statut not in ['o','f','c','d']:
74 self.cr.fatal(tr("L'attribut 'statut' doit valoir 'o','f','c' ou 'd'"))
75 if type(self.docu) != types.StringType :
76 self.cr.fatal(tr("L'attribut 'docu' doit etre une chaine de caracteres"))
77 self.verif_cata_regles()
79 def __call__(self,val,nom,parent):
81 Construit la structure de donnees pour un NUPLET a partir de sa definition (self)
82 de sa valeur (val), de son nom (nom) et de son parent dans l arboresence (parent)
84 if (type(val) == types.TupleType or type(val) == types.ListType) and type(val[0]) == types.TupleType:
85 # On est en presence d une liste de nuplets
86 l=self.list_instance()
87 l.init(nom=nom,parent=parent)
89 objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent)
93 # on est en presence d un seul nuplet
94 return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
98 Méthode qui crée le rapport de vérification du catalogue du nuplet
102 for v in self.entites :
104 cr.debut =tr("Debut ")+v.__class__.__name__+ ' : '
105 cr.fin =tr("Fin ")+v.__class__.__name__+ ' : '
109 def affecter_parente(self):
111 Cette methode a pour fonction de donner un nom et un pere aux
112 sous entités qui n'ont aucun moyen pour atteindre leur parent
114 Il s'agit principalement des mots cles
117 for v in self.entites: