Salome HOME
etat provisoire pour sauvegarde avant vacances. non stable
[tools/eficas.git] / Extensions / jdc_include.py
index 8a74ee420e15527518299a11873666a1ce63b1ad..ba4f84ff039d32b507d158ecc8e41a3effc649a7 100644 (file)
@@ -1,23 +1,22 @@
 # -*- coding: utf-8 -*-
-#            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.
 #
-# 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.
+# 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
 #
-# ======================================================================
 
 """
    Ce module contient la classe JDC_INCLUDE qui sert a inclure
@@ -27,6 +26,7 @@
    que le jeu de commandes inclus est valide et compatible
    avec le contexte avant et apres l'insertion
 """
+import string
 from Accas import JDC,ASSD,AsException,JDC_CATA
 from Ihm import CONNECTOR
 
@@ -53,6 +53,9 @@ class JDC_POURSUITE(JDC):
       if recorded_units is not None:self.recorded_units=recorded_units
       if old_recorded_units is not None:self.old_recorded_units=old_recorded_units
 
+   def o_register(self,sd):
+      return self.jdc_pere.o_register(sd)
+
    def NommerSdprod(self,sd,sdnom,restrict='non'):
       """
           Nomme la SD apres avoir verifie que le nommage est possible : nom
@@ -64,9 +67,31 @@ class JDC_POURSUITE(JDC):
       #print "NommerSdprod",sd,sdnom,restrict
       if self.prefix_include:
           if sdnom != self.prefix_include:sdnom=self.prefix_include+sdnom
+
+      if sdnom != '' and sdnom[0] == '_':
+        # Si le nom du concept commence par le caractere _ on lui attribue
+        # un identificateur automatique comme dans JEVEUX (voir gcncon)
+        # 
+        # nom commencant par __ : il s'agit de concepts qui seront detruits
+        # nom commencant par _ : il s'agit de concepts intermediaires qui seront gardes
+        # ATTENTION : il faut traiter différemment les concepts dont le nom
+        # commence par _ mais qui sont des concepts nommés automatiquement par
+        # une éventuelle sous macro.
+        if sdnom[1] in string.digits:
+          # Ce concept provient probablement d'une sous macro (cas improbable)
+          #pas de renommage
+          pass
+        elif sdnom[1] == '_':
+          #cas d'un concept à ne pas conserver apres execution de la commande
+          sdnom=sd.id[2:]
+          pass
+        else:
+          sdnom=sd.id[2:]
+          pass
+
       o=self.sds_dict.get(sdnom,None)
       if isinstance(o,ASSD):
-         raise AsException("Nom de concept deja defini : %s" % sdnom)
+         raise AsException(tr("Nom de concept deja defini : %s" ,sdnom))
 
       # On pourrait verifier que le jdc_pere apres l'etape etape_include
       # ne contient pas deja un concept de ce nom
@@ -328,7 +353,9 @@ class JDC_CATA_POURSUITE(JDC_CATA):
 
 from Accas import AU_MOINS_UN,A_CLASSER
 
-JdC_include=JDC_CATA_INCLUDE(code='ASTER', execmodul=None)
+import prefs
+c=prefs.code
+JdC_include=JDC_CATA_INCLUDE(code=c, execmodul=None)
 
 JdC_poursuite=JDC_CATA_POURSUITE(code='ASTER', execmodul=None,
                                  regles = (AU_MOINS_UN('DEBUT','POURSUITE'),