Salome HOME
*** empty log message ***
[tools/eficas.git] / Noyau / N_FACT.py
index 0cf0289532d458818259a9c37e1f63024cdbaad8..c92c59348e22987a0e55a73e61e8c5394867b8af 100644 (file)
@@ -1,3 +1,26 @@
+#@ MODIF N_FACT Noyau  DATE 14/09/2004   AUTEUR MCOURTOI M.COURTOIS 
+# -*- coding: iso-8859-1 -*-
+#            CONFIGURATION MANAGEMENT OF EDF VERSION
+# ======================================================================
+# COPYRIGHT (C) 1991 - 2002  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 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 de definition FACT
     qui permet de spécifier les caractéristiques des mots clés facteurs
 """
@@ -27,7 +50,7 @@ class FACT(N_ENTITE.ENTITE):
    label = 'FACT'
 
    def __init__(self,fr="",ang="",docu="",regles=(),statut='f',defaut=None,
-                     min=0,max=1,**args):
+                     min=0,max=1,validators=None,**args):
      
       """
           Un mot-clé facteur est caractérisé par les attributs suivants :
@@ -50,6 +73,7 @@ class FACT(N_ENTITE.ENTITE):
 
           - docu
       """
+      N_ENTITE.ENTITE.__init__(self,validators)
       # Initialisation des attributs
       self.fr=fr
       self.ang=ang
@@ -98,34 +122,37 @@ class FACT(N_ENTITE.ENTITE):
           print "On ne devrait jamais passer par la"
           return None
 
-      if type(val) == types.TupleType or type(val) == types.ListType :
-        # on est en présence d'un MCFACT multiple !
-        l=self.list_instance()
-        l.init(nom = nom,parent=parent)
-        for v in val:
-          objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent)
-          l.append(objet)
-        return l
+      # On cree toujours une liste de mcfact
+      l=self.list_instance()
+      l.init(nom = nom,parent=parent)
+      if type(val) in (types.TupleType,types.ListType) :
+         for v in val:
+            objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent)
+            l.append(objet)
       else:
-        return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
+         objet=self.class_instance(nom=nom,definition=self,val=val,parent=parent)
+         l.append(objet)
 
+      return l
 
    def verif_cata(self):
       if type(self.min) != types.IntType :
          if self.min != '**':
-            self.cr.fatal("L'attribut 'min' doit être un entier : %s" %`self.min`)
+            self.cr.fatal("L'attribut 'min' doit etre un entier : %s" %`self.min`)
       if type(self.max) != types.IntType :
          if self.max != '**':
-            self.cr.fatal("L'attribut 'max' doit être un entier : %s" %`self.max`)
+            self.cr.fatal("L'attribut 'max' doit etre un entier : %s" %`self.max`)
       if self.min > self.max :
          self.cr.fatal("Nombres d'occurrence min et max invalides : %s %s" %(`self.min`,`self.max`))
       if type(self.fr) != types.StringType :
-         self.cr.fatal("L'attribut 'fr' doit être une chaîne de caractères : %s" %`self.fr`)
+         self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" %`self.fr`)
       if type(self.regles) != types.TupleType :
-         self.cr.fatal("L'attribut 'regles' doit être un tuple : %s" %`self.regles`)
+         self.cr.fatal("L'attribut 'regles' doit etre un tuple : %s" %`self.regles`)
       if self.statut not in ['f','o','c','d'] :
          self.cr.fatal("L'attribut 'statut' doit valoir 'o','f','c' ou 'd' : %s" %`self.statut`)
       if type(self.docu) != types.StringType :
-         self.cr.fatal("L'attribut 'docu' doit être une chaîne de caractères : %s" %`self.docu`)
+         self.cr.fatal("L'attribut 'docu' doit etre une chaine de caractères : %s" %`self.docu`)
+      if self.validators and not self.validators.verif_cata():
+         self.cr.fatal("Un des validateurs est incorrect. Raison : "+self.validators.cata_info)
       self.verif_cata_regles()