# -*- 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 lire un catalogue et a construire
un objet CataItem pour Eficas.
# Modules Eficas
from Noyau.N_CR import CR
from Editeur.catadesc import CatalogDescription
-from Editeur.utils import init_rep_cata_dev
import analyse_catalogue
import analyse_catalogue_initial
import autre_analyse_cata
import uiinfo
from monChoixCata import MonChoixCata
+from Extensions.i18n import tr
+from Extensions.eficas_exception import EficasException
from PyQt4 import *
from PyQt4.QtGui import *
self.code=self.QWParent.code
self.ssCode=self.appliEficas.ssCode
self.appliEficas.format_fichier='python'
- if hasattr(self.appliEficas,'mode_nouv_commande'):
- self.mode_nouv_commande=self.appliEficas.mode_nouv_commande
- else :
- self.mode_nouv_commande='alpha'
+ self.mode_nouv_commande=self.appliEficas.CONFIGURATION.mode_nouv_commande
self.version_code=self.QWParent.version_code
self.version_cata=None
self.fic_cata=None
self.OpenCata()
self.cataitem=None
+ if self.code=="TELEMAC": self.cree_dico_inverse()
def OpenCata(self):
"""
- Ouvre le catalogue standard du code courant, cad le catalogue présent
- dans le répertoire Cata
+ Ouvre le catalogue standard du code courant, cad le catalogue present
+ dans le repertoire Cata
"""
liste_cata_possibles=[]
liste_cata_possibles = all_cata_list
else:
for catalogue in all_cata_list:
- #print catalogue.code
- #print catalogue.file_format
if catalogue.code == self.code and catalogue.file_format == self.ssCode:
liste_cata_possibles.append(catalogue)
- #print "___________"
- #print self.ssCode
- #print self.code
if len(liste_cata_possibles)==0:
- QMessageBox.critical(self.QWParent, "Import du catalogue",
- u"Pas de catalogue défini pour le code %s" % self.code)
+ QMessageBox.critical(self.QWParent, tr("Import du catalogue"),
+ tr("Pas de catalogue defini pour le code ") + self.code)
self.appliEficas.close()
if self.appliEficas.salome == 0 :
sys.exit(1)
else :
cata_choice_list.append(cata)
if len(cata_choice_list) == 0:
- QMessageBox.critical(self.QWParent, "Import du catalogue",
- QString.fromUtf8("Aucun catalogue trouvé"))
+ QMessageBox.critical(self.QWParent, tr("Import du catalogue"),
+ tr("Aucun catalogue trouve"))
self.appliEficas.close()
if self.appliEficas.salome == 0 :
sys.exit(1)
self.version_code = cata_choice_list[0].identifier
self.appliEficas.format_fichier = cata_choice_list[0].file_format
self.appliEficas.format_fichier_in = cata_choice_list[0].file_format_in
- lab=QString("Eficas ")
- lab+=QString(self.VERSION_EFICAS)
- lab+=QString(" pour ")
- lab+=QString(self.code)
- lab+=QString(" avec le catalogue ")
- lab+=self.version_code
- try :
- # souci pour les includes et sans Ihm
- self.appliEficas.setWindowTitle(lab)
- except :
- pass
else:
# plusieurs catalogues sont disponibles : il faut demander a l'utilisateur
# lequel il veut utiliser ...
self.ask_choix_catalogue(cata_choice_list)
- # On est dans Salome et il faut sortir proprement
if self.fic_cata == None :
if self.appliEficas.salome == 0 :
self.appliEficas.close()
return
- self.determineMater()
- # détermination de fic_cata_c et fic_cata_p
- self.fic_cata_c = self.fic_cata + 'c'
- self.fic_cata_p = os.path.splitext(self.fic_cata)[0]+'_pickled.py'
+ if self.code == "ASTER" : self.determineMater()
# import du catalogue
self.cata = self.import_cata(self.fic_cata)
if not self.cata :
- QMessageBox.critical( self.QWParent, "Import du catalogue","Impossible d'importer le catalogue %s" %self.fic_cata)
+ QMessageBox.critical( self.QWParent, tr("Import du catalogue"),tr("Impossible d'importer le catalogue ")+ self.fic_cata)
self.appliEficas.close()
if self.appliEficas.salome == 0 :
sys.exit(1)
#
- # analyse du catalogue (ordre des mots-clés)
+ # analyse du catalogue (ordre des mots-cles)
#
# Retrouve_Ordre_Cata_Standard fait une analyse textuelle du catalogue
- # remplacé par Retrouve_Ordre_Cata_Standard_autre qui utilise une numerotation
- # des mots clés a la création
+ # remplace par Retrouve_Ordre_Cata_Standard_autre qui utilise une numerotation
+ # des mots cles a la creation
self.Retrouve_Ordre_Cata_Standard_autre()
- if self.mode_nouv_commande== "initial" :
- self.Retrouve_Ordre_Cata_Standard()
+ if self.mode_nouv_commande== "initial" : self.Retrouve_Ordre_Cata_Standard()
+ if hasattr(self.cata, 'Ordre_Des_Commandes') : self.Ordre_Des_Commandes=self.cata.Ordre_Des_Commandes
+ else : self.Ordre_Des_Commandes=None
+
+ if hasattr(self.cata, 'Classement_Commandes_Ds_Arbre') :
+ self.Classement_Commandes_Ds_Arbre=self.cata.Classement_Commandes_Ds_Arbre
+ else : self.Classement_Commandes_Ds_Arbre=()
+ #print self.cata.Ordre_Des_Commandes
#
- # analyse des données liées a l'IHM : UIinfo
+ # analyse des donnees liees l'IHM : UIinfo
#
uiinfo.traite_UIinfo(self.cata)
#
# traitement des clefs documentaires
#
- self.traite_clefs_documentaires()
+ if self.code == "ASTER" : self.traite_clefs_documentaires()
self.cata=(self.cata,)
- titre=self.VERSION_EFICAS + " avec le catalogue " + os.path.basename(self.fic_cata)
+
+ self.titre=self.VERSION_EFICAS+" "+tr( " avec le catalogue ") + os.path.basename(self.fic_cata)
if self.appliEficas.top:
- self.appliEficas.setWindowTitle(titre)
- self.appliEficas.titre=titre
- self.QWParent.titre=titre
+ self.appliEficas.setWindowTitle(self.titre)
+ self.appliEficas.titre=self.titre
+ self.QWParent.titre=self.titre
def determineMater(self) :
# Determinination du repertoire materiau
def import_cata(self,cata):
"""
- Réalise l'import du catalogue dont le chemin d'acces est donné par cata
+ Realise l'import du catalogue dont le chemin d'acces est donne par cata
"""
nom_cata = os.path.splitext(os.path.basename(cata))[0]
rep_cata = os.path.dirname(cata)
sys.path[:0] = [rep_cata]
+ self.appliEficas.listeAEnlever.append(rep_cata)
+
if sys.modules.has_key(nom_cata):
del sys.modules[nom_cata]
if k[0:len(nom_cata)+1] == nom_cata+'.':
del sys.modules[k]
+ mesScriptsNomFichier='mesScripts_'+self.code.upper()
+ if self.code == "ASTER" :
+ self.appliEficas.rep_scripts=os.path.join(rep_cata,nom_cata)
+ sys.path[:0] = [self.appliEficas.rep_scripts]
+ try :
+ self.appliEficas.mesScripts=__import__(mesScriptsNomFichier)
+ except:
+ pass
+ sys.path=sys.path[1:]
+ else :
+ try :
+ self.appliEficas.mesScripts=__import__(mesScriptsNomFichier)
+ except:
+ pass
+
try :
o=__import__(nom_cata)
return o
traceback.print_exc()
return 0
+
+
def Retrouve_Ordre_Cata_Standard_autre(self):
"""
- Construit une structure de données dans le catalogue qui permet
- a EFICAS de retrouver l'ordre des mots-clés dans le texte du catalogue.
- Pour chaque entité du catlogue on crée une liste de nom ordre_mc qui
- contient le nom des mots clés dans le bon ordre
+ Construit une structure de donnees dans le catalogue qui permet
+ a EFICAS de retrouver l'ordre des mots-cles dans le texte du catalogue.
+ Pour chaque entite du catlogue on cree une liste de nom ordre_mc qui
+ contient le nom des mots cles dans le bon ordre
"""
self.cata_ordonne_dico,self.appliEficas.liste_simp_reel=autre_analyse_cata.analyse_catalogue(self.cata)
+ #print self.cata_ordonne_dico,self.appliEficas.liste_simp_reel
def Retrouve_Ordre_Cata_Standard(self):
"""
- Retrouve l'ordre des mots-clés dans le catalogue, cad :
+ Retrouve l'ordre des mots-cles dans le catalogue, cad :
Attention s appuie sur les commentaires
"""
nom_cata = os.path.splitext(os.path.basename(self.fic_cata))[0]
rep_cata = os.path.dirname(self.fic_cata)
self.Commandes_Ordre_Catalogue = analyse_catalogue_initial.analyse_catalogue(self.fic_cata)
+ #print self.Commandes_Ordre_Catalogue
def ask_choix_catalogue(self, cata_choice_list):
"""
- Ouvre une fenetre de sélection du catalogue dans le cas où plusieurs
- ont été définis dans Accas/editeur.ini
+ Ouvre une fenetre de selection du catalogue dans le cas où plusieurs
+ ont ete definis dans Accas/editeur.ini
"""
code = getattr(self.appliEficas.CONFIGURATION, "code", None)
if code != None :
- title="Choix d une version du code "+str(code)
+ title=tr("Choix d une version du code ")+str(code)
else :
- title="Choix d une version "
+ title=tr("Choix d une version ")
widgetChoix = MonChoixCata(self.appliEficas, [cata.user_name for cata in cata_choice_list], title)
ret=widgetChoix.exec_()
- lab=QString(self.VERSION_EFICAS)
- lab+=QString(" pour ")
+ lab=QString(self.VERSION_EFICAS)+" "
+ lab+=tr(" pour ")
lab+=QString(self.code)
- lab+=QString(" avec le catalogue ")
+ lab+=tr(" avec le catalogue ")
if ret == QDialog.Accepted:
cata = cata_choice_list[widgetChoix.CBChoixCata.currentIndex()]
self.version_cata = cata.identifier
self.appliEficas.setWindowTitle(lab)
#qApp.mainWidget().setCaption(lab)
else:
- self.appliEficas.close()
- if self.appliEficas.salome == 0 :
- sys.exit(0)
+ raise EficasException()
def traite_clefs_documentaires(self):
try:
- self.fic_cata_clef=os.path.splitext(self.fic_cata_c)[0]+'_clefs_docu'
- #print self.fic_cata_clef
- f=open(self.fic_cata_clef)
+ fic_doc='rep_doc_'+str(self.version_code)
+ self.fic_doc=getattr(self.appliEficas.CONFIGURATION,fic_doc )
+ f=open(self.fic_doc)
except:
- #print "Pas de fichier associe contenant des clefs documentaires"
+ print "Pas de fichier associe contenant des clefs documentaires"
return
dict_clef_docu={}
for l in f.readlines():
clef=l.split(':')[0]
- docu=l.split(':')[1]
- docu=docu[0:-1]
+ deb=l.find(':')+1
+ docu=l[deb:-1]
dict_clef_docu[clef]=docu
for oper in self.cata.JdC.commandes:
if dict_clef_docu.has_key(oper.nom):
oper.docu=dict_clef_docu[oper.nom]
+
+
+ def cree_dico_inverse(self):
+ self.dicoInverse={}
+ self.dico={}
+ listeEtapes=self.cata[0].JdC.commandes
+ for e in self.cata[0].JdC.commandes:
+ self.traite_entite(e)
+ #print self.dicoInverse.keys()
+ #for e in self.cata[0].JdC.commandes:
+ # print "___________", e. nom , '__________________'
+ # self.cree_rubrique(e,self.dico,0)
+
+
+ def traite_entite(self,e):
+ boolIn=0
+ for (nomFils, fils) in e.entites.items() :
+ self.traite_entite(fils)
+ boolIn=1
+ if boolIn==0 :
+ liste=[]
+ moi=e
+ while hasattr(moi,'pere') :
+ liste.append((moi.nom,moi))
+ moi=moi.pere
+ liste.append((moi.nom,moi))
+ self.dicoInverse[e.nom]=liste
+
+ def cree_rubrique(self,e,dico, niveau):
+ from Accas import A_BLOC
+ decale=niveau*" "
+ if niveau != 0 :
+ if isinstance(e,A_BLOC.BLOC): print decale, e.condition
+ else : print decale, e. nom
+ for (nom, fils) in e.entites.items() :
+ if fils.entites.items() != [] : self.cree_rubrique(fils,dico,niveau+1)
+ else : print (niveau+1)*" ", nom
+
+
+
+
+