Salome HOME
gitignore V1
[tools/eficas.git] / Validation / V_PROC_ETAPE.py
index 4120de8352ea7a5d9caeb2ba54cac5b62bacd660..8399ede193cc2ae88faa8cf02012dbcc8cd03eec 100644 (file)
@@ -1,3 +1,23 @@
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2013   EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 """
    Ce module contient la classe mixin PROC_ETAPE qui porte les méthodes
    nécessaires pour réaliser la validation d'un objet de type PROC_ETAPE
    Une classe mixin porte principalement des traitements et est
    utilisée par héritage multiple pour composer les traitements.
 """
-# Modules Python
-import string,types
-
 # Modules EFICAS
 import V_ETAPE
 from Noyau.N_Exception import AsException
 from Noyau.N_utils import AsType
+from Noyau.strfunc import ufmt
+
 
 class PROC_ETAPE(V_ETAPE.ETAPE):
    """
-      On réutilise les méthodes report,verif_regles 
+      On réutilise les méthodes report,verif_regles
       de ETAPE par héritage.
    """
 
    def isvalid(self,sd='oui',cr='non'):
-      """ 
+      """
          Methode pour verifier la validité de l'objet PROC_ETAPE. Cette méthode
          peut etre appelée selon plusieurs modes en fonction de la valeur
          de sd et de cr (sd n'est pas utilisé).
@@ -35,35 +54,18 @@ class PROC_ETAPE(V_ETAPE.ETAPE):
           - produire un compte-rendu : self.cr
 
           - propager l'éventuel changement d'état au parent
-
       """
       if CONTEXT.debug : print "ETAPE.isvalid ",self.nom
       if self.state == 'unchanged' :
         return self.valid
       else:
-        valid = 1
-        if hasattr(self,'valid'):
-          old_valid = self.valid
-        else:
-          old_valid = None
-        # on teste les enfants
-        for child in self.mc_liste :
-          if not child.isvalid():
-            valid = 0
-            break
-        # on teste les règles de self
-        text_erreurs,test_regles = self.verif_regles()
-        if not test_regles :
-          if cr == 'oui' : self.cr.fatal(string.join(("Règle(s) non respectée(s) :", text_erreurs)))
-          valid = 0
+        valid=self.valid_child()
+        valid=valid * self.valid_regles(cr)
         if self.reste_val != {}:
           if cr == 'oui' :
-            self.cr.fatal("Mots cles inconnus :" + string.join(self.reste_val.keys(),','))
+            self.cr.fatal(_(u"Mots clés inconnus : %s"), ','.join(self.reste_val.keys()))
           valid=0
-        self.valid = valid
-        self.state = 'unchanged'
-        if old_valid:
-          if old_valid != self.valid : self.init_modif_up()
+        self.set_valid(valid)
         return self.valid