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
22 Ce module contient la classe mixin MCFACT qui porte les méthodes
23 nécessaires pour réaliser la validation d'un objet de type MCFACT
26 Une classe mixin porte principalement des traitements et est
27 utilisée par héritage multiple pour composer les traitements.
31 from Noyau.strfunc import ufmt
33 class MCFACT(V_MCCOMPO.MCCOMPO):
35 Cette classe a un attribut de classe :
37 - txt_nat qui sert pour les comptes-rendus liés à cette classe
40 txt_nat = u"Mot clé Facteur :"
42 def isvalid(self,sd='oui',cr='non'):
44 Methode pour verifier la validité du MCFACT. Cette méthode
45 peut etre appelée selon plusieurs modes en fonction de la valeur
48 Si cr vaut oui elle crée en plus un compte-rendu
49 sd est présent pour compatibilité de l'interface mais ne sert pas
51 if self.state == 'unchanged' :
55 if hasattr(self,'valid'):
56 old_valid = self.valid
59 for child in self.mc_liste :
60 if not child.isvalid():
63 # Après avoir vérifié la validité de tous les sous-objets, on vérifie
64 # la validité des règles
65 text_erreurs,test_regles = self.verif_regles()
67 if cr == 'oui' : self.cr.fatal(_(u"Règle(s) non respectée(s) : %s"), text_erreurs)
70 # On verifie les validateurs s'il y en a
72 if self.definition.validators and not self.definition.validators.verif(self.valeur):
74 self.cr.fatal(_(u"Mot-clé : %s devrait avoir %s"),
75 self.nom, self.definition.validators.info())
79 if self.reste_val != {}:
81 self.cr.fatal(_(u"Mots clés inconnus : %s"), ','.join(self.reste_val.keys()))
84 self.state = 'unchanged'
85 if not old_valid or old_valid != self.valid :