-# -*- 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 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.
#
-# 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 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.
#
-# 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 MCBLOC qui porte les méthodes
- nécessaires pour réaliser la validation d'un objet de type MCBLOC
- dérivé de OBJECT.
+ Ce module contient la classe mixin MCBLOC qui porte les methodes
+ necessaires pour realiser la validation d'un objet de type MCBLOC
+ 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 absolute_import
# Modules EFICAS
-import V_MCCOMPO
-from Noyau.strfunc import ufmt
+from . import V_MCCOMPO
+
class MCBLOC(V_MCCOMPO.MCCOMPO):
- """
- Cette classe a un attribut de classe :
- - txt_nat qui sert pour les comptes-rendus liés à cette classe
- """
+ """
+ Cette classe a un attribut de classe :
- txt_nat = u"Bloc :"
+ - txt_nat qui sert pour les comptes-rendus lies a cette classe
+ """
- def isvalid(self,sd='oui',cr='non'):
- """
- Methode pour verifier la validité du MCBLOC. Cette méthode
- peut etre appelée selon plusieurs modes en fonction de la valeur
- de sd et de cr.
+ txt_nat = u"Bloc :"
- Si cr vaut oui elle crée en plus un compte-rendu
- sd est présent pour compatibilité de l'interface mais ne sert pas
- """
- if self.state == 'unchanged' :
- return self.valid
- else:
- valid = 1
- if hasattr(self,'valid'):
- old_valid = self.valid
- else:
- old_valid = None
- for child in self.mc_liste :
- if not child.isvalid():
- valid = 0
- break
- # Après avoir vérifié la validité de tous les sous-objets, on vérifie
- # la validité des règles
- text_erreurs,test_regles = self.verif_regles()
- if not test_regles :
- if cr == 'oui':
- self.cr.fatal(_(u"Règle(s) non respectée(s) : %s"), text_erreurs)
- valid = 0
- self.valid = valid
- self.state = 'unchanged'
- if not old_valid or old_valid != self.valid :
- self.init_modif_up()
- return self.valid
+ def isValid(self, sd='oui', cr='non'):
+ """
+ Methode pour verifier la validite du MCBLOC. Cette methode
+ peut etre appelee selon plusieurs modes en fonction de la valeur
+ de sd et de cr.
+ Si cr vaut oui elle cree en plus un compte-rendu
+ sd est present pour compatibilite de l'interface mais ne sert pas
+ """
+ if self.state == 'unchanged':
+ return self.valid
+ else:
+ valid = 1
+ if hasattr(self, 'valid'):
+ old_valid = self.valid
+ else:
+ old_valid = None
+ for child in self.mcListe:
+ if not child.isValid():
+ valid = 0
+ break
+ # Apres avoir verifie la validite de tous les sous-objets, on verifie
+ # la validite des regles
+ text_erreurs, test_regles = self.verifRegles()
+ if not test_regles:
+ if cr == 'oui':
+ self.cr.fatal( "Regle(s) non respectee(s) : %s" % text_erreurs)
+ valid = 0
+ self.valid = valid
+ self.state = 'unchanged'
+ if not old_valid or old_valid != self.valid:
+ self.initModifUp()
+ return self.valid