Salome HOME
TypeInstance and basestring
[tools/eficas.git] / Validation / V_PROC_ETAPE.py
index 8399ede193cc2ae88faa8cf02012dbcc8cd03eec..edd5b1388e773a894cc0b6cd6b91aa9cc17a6e42 100644 (file)
@@ -1,71 +1,73 @@
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013   EDF R&D
+# coding=utf-8
+# person_in_charge: mathieu.courtois at edf.fr
+# ======================================================================
+# COPYRIGHT (C) 1991 - 2017  EDF R&D                  WWW.CODE-ASTER.ORG
+# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
+# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
+# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
+# (AT YOUR OPTION) ANY LATER VERSION.
 #
-# 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
+# THIS PROGRAM 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
+# GENERAL PUBLIC LICENSE FOR MORE DETAILS.
 #
+# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
+# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
+#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
+# ======================================================================
 
 """
-   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
-   dérivé de OBJECT.
+   Ce module contient la classe mixin PROC_ETAPE qui porte les methodes
+   necessaires pour realiser la validation d'un objet de type PROC_ETAPE
+   derive de OBJECT.
 
    Une classe mixin porte principalement des traitements et est
-   utilisée par héritage multiple pour composer les traitements.
+   utilisee par heritage multiple pour composer les traitements.
 """
+from __future__ import print_function
+from __future__ import absolute_import
 # Modules EFICAS
-import V_ETAPE
+from . import V_ETAPE
 from Noyau.N_Exception import AsException
 from Noyau.N_utils import AsType
-from Noyau.strfunc import ufmt
+from Extensions.i18n import tr
 
 
 class PROC_ETAPE(V_ETAPE.ETAPE):
-   """
-      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é).
 
-         Si cr vaut oui elle crée en plus un compte-rendu.
+    """
+       On reutilise les methodes report,verifRegles
+       de ETAPE par heritage.
+    """
 
-         Cette méthode a plusieurs fonctions :
+    def isValid(self, sd='oui', cr='non'):
+        """
+           Methode pour verifier la validite de l'objet PROC_ETAPE. Cette methode
+           peut etre appelee selon plusieurs modes en fonction de la valeur
+           de sd et de cr (sd n'est pas utilise).
 
-          - retourner un indicateur de validité 0=non, 1=oui
+           Si cr vaut oui elle cree en plus un compte-rendu.
 
-          - produire un compte-rendu : self.cr
+           Cette methode a plusieurs fonctions :
 
-          - 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=self.valid_child()
-        valid=valid * self.valid_regles(cr)
-        if self.reste_val != {}:
-          if cr == 'oui' :
-            self.cr.fatal(_(u"Mots clés inconnus : %s"), ','.join(self.reste_val.keys()))
-          valid=0
-        self.set_valid(valid)
-        return self.valid
+            - retourner un indicateur de validite 0=non, 1=oui
 
+            - produire un compte-rendu : self.cr
 
+            - propager l'eventuel changement d'etat au parent
+        """
+        if CONTEXT.debug:
+            print(("ETAPE.isValid ", self.nom))
+        if self.state == 'unchanged':
+            return self.valid
+        else:
+            valid = self.validChild()
+            valid = valid * self.validRegles(cr)
+            if self.reste_val != {}:
+                if cr == 'oui':
+                    self.cr.fatal(
+                        tr("unknown keywords : %s") % ','.join(list(self.reste_val.keys())))
+                valid = 0
+            self.setValid(valid)
+            return self.valid