Salome HOME
travail sur monPlusieurs
[tools/eficas.git] / Noyau / N_MACRO.py
index d4f162f566dd037e38b38c56c8cc540932f888da..e4fdbb27395fd031a6aca1a1e72e2c34a8870a37 100644 (file)
@@ -1,27 +1,25 @@
-#@ MODIF N_MACRO 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.                                 
+# Copyright (C) 2007-2013   EDF R&D
 #
-# 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 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
 #
-# 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 MACRO
     qui permet de spécifier les caractéristiques d'une macro-commande
 """
@@ -31,15 +29,16 @@ import types,string,traceback
 import N_ENTITE
 import N_MACRO_ETAPE
 import nommage
+from strfunc import ufmt
 
 class MACRO(N_ENTITE.ENTITE):
    """
     Classe pour definir une macro-commande
 
-    Cette classe a trois attributs de classe 
+    Cette classe a trois attributs de classe
 
-    - class_instance qui indique la classe qui devra etre utilisée 
-            pour créer l'objet qui servira à controler la conformité d'un 
+    - class_instance qui indique la classe qui devra etre utilisée
+            pour créer l'objet qui servira à controler la conformité d'un
             macro-commande avec sa définition
 
     - label qui indique la nature de l'objet de définition (ici, MACRO)
@@ -120,7 +119,7 @@ class MACRO(N_ENTITE.ENTITE):
       self.fichier_ini = fichier_ini
       # Attribut op_init : Fonction a appeler a la construction de l operateur sauf si == None
       self.op_init=op_init
-      self.entites=args
+      self.entites = args
       current_cata=CONTEXT.get_current_cata()
       if niveau == None:
          self.niveau=None
@@ -130,14 +129,15 @@ class MACRO(N_ENTITE.ENTITE):
          self.niveau.enregistre(self)
       self.UIinfo=UIinfo
       self.affecter_parente()
+      self.check_definition(self.nom)
 
    def __call__(self,reuse=None,**args):
       """
           Construit l'objet MACRO_ETAPE a partir de sa definition (self),
           puis demande la construction de ses sous-objets et du concept produit.
       """
-      nomsd=self.nommage.GetNomConceptResultat(self.nom)
-      etape= self.class_instance(oper=self,reuse=reuse,args=args)
+      nomsd = self.nommage.GetNomConceptResultat(self.nom)
+      etape = self.class_instance(oper=self,reuse=reuse,args=args)
       etape.McBuild()
       return etape.Build_sd(nomsd)
 
@@ -157,20 +157,13 @@ class MACRO(N_ENTITE.ENTITE):
       """
           Méthode de vérification des attributs de définition
       """
-      if self.op is not None and (type(self.op) != types.IntType or self.op > 0) :
-        self.cr.fatal("L'attribut 'op' doit etre un entier signé : %s" %`self.op`)
-      if self.proc is not None and type(self.proc) != types.FunctionType:
-        self.cr.fatal("L'attribut op doit etre une fonction Python : %s" % `self.proc`)
-      if type(self.regles) != types.TupleType :
-        self.cr.fatal("L'attribut 'regles' doit etre un tuple : %s" %`self.regles`)
-      if type(self.fr) != types.StringType :
-        self.cr.fatal("L'attribut 'fr' doit etre une chaine de caractères : %s" %`self.fr`)
-      if type(self.docu) != types.StringType :
-        self.cr.fatal("L'attribut 'docu' doit etre une chaine de caractères : %s" %`self.docu` )
-      if type(self.nom) != types.StringType :
-        self.cr.fatal("L'attribut 'nom' doit etre une chaine de caractères : %s" %`self.nom`)
-      if self.reentrant not in ('o','n','f'):
-        self.cr.fatal("L'attribut 'reentrant' doit valoir 'o','n' ou 'f' : %s" %`self.reentrant`)
+      self.check_op(valmax=0)
+      self.check_proc()
+      self.check_regles()
+      self.check_fr()
+      self.check_docu()
+      self.check_nom()
+      self.check_reentrant()
       self.verif_cata_regles()
 
    def supprime(self):
@@ -180,4 +173,3 @@ class MACRO(N_ENTITE.ENTITE):
       """
       self.niveau=None
 
-