1 # -*- coding: iso-8859-1 -*-
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
23 Ce module contient la classe mixin MCList qui porte les méthodes
24 nécessaires pour réaliser la validation d'un objet de type MCList
27 Une classe mixin porte principalement des traitements et est
28 utilisée par héritage multiple pour composer les traitements.
34 from Noyau import N_CR
35 from Noyau.N_Exception import AsException
36 from Noyau.strfunc import ufmt
40 Cette classe a deux attributs de classe :
42 - CR qui sert à construire l'objet compte-rendu
44 - txt_nat qui sert pour les comptes-rendus liés à cette classe
48 txt_nat = u"Mot clé Facteur Multiple :"
50 def isvalid(self,cr='non'):
52 Methode pour verifier la validité du MCList. Cette méthode
53 peut etre appelée selon plusieurs modes en fonction de la valeur
56 Si cr vaut oui elle crée en plus un compte-rendu.
58 On n'utilise pas d'attribut pour stocker l'état et on ne remonte pas
59 le changement d'état au parent (pourquoi ??)
60 MCLIST est une liste de MCFACT. Les MCFACT ont le meme parent
61 que le MCLIST qui les contient. Il n'est donc pas necessaire de
62 remonter le changement d'etat au parent. C'est deja fait
65 if len(self.data) == 0 : return 0
68 definition=self.data[0].definition
69 # Verification du nombre des mots cles facteurs
70 if definition.min is not None and len(self.data) < definition.min :
73 self.cr.fatal(_(u"Nombre de mots clés facteurs insuffisant minimum : %s"),
76 if definition.max is not None and len(self.data) > definition.max :
79 self.cr.fatal(_(u"Nombre de mots clés facteurs trop grand maximum : %s"),
86 if cr=='oui' and len(self) > 1:
87 self.cr.fatal(_(u"L'occurrence numéro %d du mot-clé facteur : %s n'est pas valide"),
93 Génère le rapport de validation de self
96 # Mot cle facteur multiple
97 self.cr=self.CR( debut = u"Mot-clé facteur multiple : "+self.nom,
98 fin = u"Fin Mot-clé facteur multiple : "+self.nom)
100 self.cr.add(i.report())
102 # Mot cle facteur non multiple
103 self.cr=self.data[0].report()
105 self.cr=self.CR( debut = u"Mot-clé facteur : "+self.nom,
106 fin = u"Fin Mot-clé facteur : "+self.nom)
109 self.isvalid(cr='oui')
110 except AsException,e:
111 if CONTEXT.debug : traceback.print_exc()
112 self.cr.fatal(_(u"Mot-clé facteur multiple : %s, %s"), self.nom, e)