Salome HOME
version 19 mars
[tools/eficas.git] / Validation / V_PROC_ETAPE.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 """
22    Ce module contient la classe mixin PROC_ETAPE qui porte les méthodes
23    nécessaires pour réaliser la validation d'un objet de type PROC_ETAPE
24    dérivé de OBJECT.
25
26    Une classe mixin porte principalement des traitements et est
27    utilisée par héritage multiple pour composer les traitements.
28 """
29 # Modules EFICAS
30 import V_ETAPE
31 from Noyau.N_Exception import AsException
32 from Noyau.N_utils import AsType
33 from Noyau.strfunc import ufmt
34
35
36 class PROC_ETAPE(V_ETAPE.ETAPE):
37    """
38       On réutilise les méthodes report,verif_regles
39       de ETAPE par héritage.
40    """
41
42    def isvalid(self,sd='oui',cr='non'):
43       """
44          Methode pour verifier la validité de l'objet PROC_ETAPE. Cette méthode
45          peut etre appelée selon plusieurs modes en fonction de la valeur
46          de sd et de cr (sd n'est pas utilisé).
47
48          Si cr vaut oui elle crée en plus un compte-rendu.
49
50          Cette méthode a plusieurs fonctions :
51
52           - retourner un indicateur de validité 0=non, 1=oui
53
54           - produire un compte-rendu : self.cr
55
56           - propager l'éventuel changement d'état au parent
57       """
58       if CONTEXT.debug : print "ETAPE.isvalid ",self.nom
59       if self.state == 'unchanged' :
60         return self.valid
61       else:
62         valid=self.valid_child()
63         valid=valid * self.valid_regles(cr)
64         if self.reste_val != {}:
65           if cr == 'oui' :
66             self.cr.fatal(_(u"Mots clés inconnus : %s"), ','.join(self.reste_val.keys()))
67           valid=0
68         self.set_valid(valid)
69         return self.valid
70
71