Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[tools/eficas.git] / Ihm / I_MACRO_ETAPE.py
index be318d25fbf2c096767eb7c6ee8f483e9ab13758..59ddb8e9bcc275c01d6f97d58d7239fef5be3559 100644 (file)
@@ -1,3 +1,22 @@
+#            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.
+#
+#
+# ======================================================================
 """
 """
 # Modules Python
@@ -7,10 +26,19 @@ import traceback,types,string
 import I_ETAPE
 from Noyau.N_ASSD import ASSD
 
+# import rajoutés suite à l'ajout de Build_sd --> à résorber
+import Noyau
+from Noyau import N_Exception
+from Noyau.N_Exception import AsException
+# fin import à résorber
+
 class MACRO_ETAPE(I_ETAPE.ETAPE):
 
   def __init__(self):
       I_ETAPE.ETAPE.__init__(self)
+      # XXX CCAR : ne suis pas certain que typret doive etre 
+      # initialise à None (a verifier)
+      self.typret=None
 
   def get_sdprods(self,nom_sd):
     """ 
@@ -61,6 +89,10 @@ class MACRO_ETAPE(I_ETAPE.ETAPE):
                              context_ini = context_ini,
                              appli=self.jdc.appli)
        j.analyse()
+       # XXX en passant par un jdc auxiliaire, on risque de rendre les etapes inactives
+       # on les force dans l'etat actif
+       for etape in j.etapes:
+          etape.active()
     except:
        traceback.print_exc()
        return None
@@ -146,3 +178,51 @@ class MACRO_ETAPE(I_ETAPE.ETAPE):
       # On met g_context à blanc
       self.g_context={}
          
+  def Build_sd(self,nom):
+     """
+        Construit le concept produit de l'opérateur. Deux cas 
+        peuvent se présenter :
+
+        - le parent n'est pas défini. Dans ce cas, l'étape prend en charge 
+          la création et le nommage du concept.
+
+        - le parent est défini. Dans ce cas, l'étape demande au parent la 
+          création et le nommage du concept.
+
+     """
+     if not self.isactif():return
+     # CCAR : meme modification que dans I_ETAPE
+     if not self.isvalid(sd='non') : return
+     else:self.state='undetermined'
+     try:
+        # On positionne la macro self en tant que current_step pour que les 
+        # étapes créées lors de l'appel à sd_prod et à op_init aient la macro
+        #  comme parent 
+        self.set_current_step()
+        if self.parent:
+           sd= self.parent.create_sdprod(self,nom)
+           if type(self.definition.op_init) == types.FunctionType: 
+              apply(self.definition.op_init,(self,self.parent.g_context))
+        else:
+           sd=self.get_sd_prod()
+           if sd != None and self.reuse == None:
+              # On ne nomme le concept que dans le cas de non reutilisation 
+              # d un concept
+              sd.nom=nom
+        self.reset_current_step()
+        if self.jdc and self.jdc.par_lot == "NON" :
+           self.Execute()
+        return sd
+     except AsException,e:
+        self.reset_current_step()
+        raise AsException("Etape ",self.nom,'ligne : ',self.appel[0],
+                             'fichier : ',self.appel[1],e)
+     except EOFError:
+        #self.reset_current_step()
+        raise
+     except :
+        self.reset_current_step()
+        l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2])
+        raise AsException("Etape ",self.nom,'ligne : ',self.appel[0],
+                          'fichier : ',self.appel[1]+'\n',
+                           string.join(l))