Salome HOME
commentaire
[tools/eficas.git] / Editeur / autre_analyse_cata.py
index a9650f06a3d81cdaee133e96ad18eba4f95ab98c..d6411f7cd0e5ab98349208533c3bba8f5965efb2 100644 (file)
@@ -1,27 +1,28 @@
 # -*- 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 sert a retrouver l'ordre des mots cles d'un catalogue de
    commandes
 """
+from __future__ import absolute_import
+from __future__ import print_function
 if __name__ == "__main__" :
    import sys
    sys.path[:0]=[".."]
@@ -43,22 +44,34 @@ def traite_entite(entite,liste_simp_reel):
        Cette fonction ajoute a l'objet entite un attribut de nom ordre_mc
        qui est une liste contenant le nom des sous entites dans l'ordre 
        de leur apparition dans le catalogue.
-       L'ordre d'apparition dans le catalogue est donné par l'attribut _no
+       L'ordre d'apparition dans le catalogue est donne par l'attribut _no
        de l'entite
        La fonction active le meme type de traitement pour les sous entites
        de entite
    """
    l=[]
-   for k,v in entite.entites.items():
+   for k,v in list(entite.entites.items()):
       if isinstance(v,NUPL):
          traite_entiteNUPL(v)
       else:
          traite_reel(v,liste_simp_reel)
          traite_entite(v,liste_simp_reel)
+         traite_cache(v)
       l.append((v._no,k))
    l.sort()
    entite.ordre_mc=[ item for index, item in l ]
 
+def traite_cache(objet):
+    if not hasattr(objet, "cache"): return
+    if objet.cache == 0 :return
+    clef=objet.nom
+    if objet.equiv != None : clef=objet.equiv
+    if hasattr(objet.pere,"mcOblig"):
+      objet.pere.mcOblig[clef]=objet.defaut
+    else :
+      objet.pere.mcOblig={}
+      objet.pere.mcOblig[clef]=objet.defaut
+
 def traite_reel(objet,liste_simp_reel):
     if objet.__class__.__name__ == "SIMP":
        if ( 'R' in objet.type):
@@ -81,16 +94,15 @@ def analyse_niveau(cata_ordonne_dico,niveau,liste_simp_reel):
 def analyse_catalogue(cata):
    """
       Cette fonction analyse le catalogue cata pour construire avec l'aide
-      de traite_entite la structure de données ordre_mc qui donne l'ordre
-      d'apparition des mots clés dans le catalogue
+      de traite_entite la structure de donnees ordre_mc qui donne l'ordre
+      d'apparition des mots cles dans le catalogue
       Elle retourne un dictionnaire qui contient toutes les commandes
-      du catalogue indexées par leur nom
+      du catalogue indexees par leur nom
    """
    cata_ordonne_dico={}
    liste_simp_reel=[]
    if cata.JdC.l_niveaux == ():
        # Il n'y a pas de niveaux
-       a=1
        for oper in cata.JdC.commandes:
            traite_entite(oper,liste_simp_reel)
            cata_ordonne_dico[oper.nom]=oper
@@ -107,11 +119,11 @@ if __name__ == "__main__" :
    #dico=analyse_catalogue(cata_saturne)
 
    def print_entite(entite,dec='  '):
-       print dec,entite.nom,entite.__class__.__name__
+       print (dec,entite.nom,entite.__class__.__name__)
        for mocle in entite.ordre_mc:
           print_entite(entite.entites[mocle],dec=dec+'  ')
 
-   for k,v in dico.items():
+   for k,v in list(dico.items()):
       print_entite(v,dec='')
 
-   print dico.keys()
+   print (dico)