Salome HOME
merge de la branche BR_dev_mars_06 (tag V1_10b5) dans la branche principale
[tools/eficas.git] / Noyau / N_FACT.py
index 0cf0289532d458818259a9c37e1f63024cdbaad8..e5e3b4280ce21ec21f4583d0a005a301cfc2f610 100644 (file)
@@ -1,3 +1,26 @@
+#@ MODIF N_FACT Noyau  DATE 16/05/2006   AUTEUR DURAND C.DURAND 
+# -*- 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
 """
@@ -7,6 +30,9 @@ import types
 import N_ENTITE
 import N_MCFACT
 import N_MCLIST
+from N__F import _F
+
+import N_OBJECT 
 
 class FACT(N_ENTITE.ENTITE):
    """
@@ -27,7 +53,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 +76,7 @@ class FACT(N_ENTITE.ENTITE):
 
           - docu
       """
+      N_ENTITE.ENTITE.__init__(self,validators)
       # Initialisation des attributs
       self.fr=fr
       self.ang=ang
@@ -91,41 +118,49 @@ class FACT(N_ENTITE.ENTITE):
         elif type(self.defaut) == types.TupleType:
           val=self.defaut
               # Est ce utile ? Le défaut pourrait etre uniquement un dict
-        elif type(self.defaut) == types.DictType or isinstance(self.defaut,N_MCFACT._F):
+        elif type(self.defaut) == types.DictType or isinstance(self.defaut,_F):
           val=self.defaut
         else:
           # On ne devrait jamais passer par la
           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:
+            if type(v) == types.DictType or isinstance(v, _F):
+               objet=self.class_instance(nom=nom,definition=self,val=v,parent=parent)
+               l.append(objet)
+            else:
+               l.append(N_OBJECT.ErrorObj(self,v,parent,nom))
+      elif type(val) == types.DictType or isinstance(val, _F):
+         objet=self.class_instance(nom=nom,definition=self,val=val,parent=parent)
+         l.append(objet)
       else:
-        return self.class_instance(nom=nom,definition=self,val=val,parent=parent)
+         l.append(N_OBJECT.ErrorObj(self,val,parent,nom))
 
+      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()