From 54d68742db503e057cbd02c2c4035a70c93e2613 Mon Sep 17 00:00:00 2001 From: eficas <> Date: Thu, 16 Sep 2004 08:32:11 +0000 Subject: [PATCH] PN : report des modifs pour Homard --- Homard/eficas_homard.py | 13 +- Homard/homard_cata_STA7.py | 4 +- Homard/prefs.py | 66 +++++++++++ Homard/properties.py | 26 +++- convert/convert_homard.py | 125 ++++++++++++++++++++ generator/generator_homard.py | 216 ++++++++++++++++++++++++++++++++++ 6 files changed, 442 insertions(+), 8 deletions(-) create mode 100644 convert/convert_homard.py create mode 100644 generator/generator_homard.py diff --git a/Homard/eficas_homard.py b/Homard/eficas_homard.py index 599ba190..a77735d1 100755 --- a/Homard/eficas_homard.py +++ b/Homard/eficas_homard.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- #!/usr/bin/env python +# -*- coding: utf-8 -*- # CONFIGURATION MANAGEMENT OF EDF VERSION # ====================================================================== # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG @@ -21,13 +21,21 @@ # ====================================================================== """ - Ce module sert \xe0 lancer EFICAS configur\xe9 pour Code_Aster + Ce module sert à lancer EFICAS configuré pour Code_Aster """ # Modules Python import sys # Modules Eficas import prefs +if hasattr(prefs,'encoding'): + # Hack pour changer le codage par defaut des strings + import sys + reload(sys) + sys.setdefaultencoding(prefs.encoding) + del sys.setdefaultencoding + # Fin hack + sys.path[:0]=[prefs.INSTALLDIR] import Editeur @@ -39,4 +47,3 @@ if len(sys.argv) > 1 : else: # on veut ouvrir Eficas 'vide' eficas_go.lance_eficas(code='HOMARD') - diff --git a/Homard/homard_cata_STA7.py b/Homard/homard_cata_STA7.py index 66a08f18..159ca29d 100755 --- a/Homard/homard_cata_STA7.py +++ b/Homard/homard_cata_STA7.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -------------------------------------------------- # debut entete # -------------------------------------------------- @@ -75,12 +75,10 @@ DONNEES_HOMARD=PROC(nom="DONNEES_HOMARD",op= 189, docu="U7.04.01-b", RAFFINEMENT =SIMP(statut='f',typ='TXM', fr="Choix du mode de raffinement.", ang="Choice of refinement mode.", - defaut="LIBRE", into=("LIBRE","UNIFORME","NON","NON-CONFORME","NON-CONFORME-INDICATEUR") ), DERAFFINEMENT =SIMP(statut='f',typ='TXM', fr="Choix du mode de deraffinement.", ang="Choice of unrefinement mode.", - defaut="LIBRE", into=("LIBRE","UNIFORME","NON") ), INFORMATION =SIMP(statut='f',typ='TXM', fr="Information sur un maillage", diff --git a/Homard/prefs.py b/Homard/prefs.py index d0cd9255..56bb96cd 100644 --- a/Homard/prefs.py +++ b/Homard/prefs.py @@ -1,4 +1,24 @@ # -*- 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. +# +# 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. +# +# +# ====================================================================== + import os # REPINI sert à localiser le fichier editeur.ini @@ -23,4 +43,50 @@ ICONDIR=os.path.join(INSTALLDIR,'Editeur','icons') # lang indique la langue utilisée pour les chaines d'aide : fr ou ang lang='fr' +# Codage des strings qui accepte les accents (en remplacement de 'ascii') +encoding='iso-8859-1' + +labels= ('Fichier','Edition','Jeu de commandes', +# 'Catalogue','Browsers', + 'Options', + 'Aide', + ) + +appli_composants=['readercata','bureau', +# 'browser', + 'options', + ] + +menu_defs={ 'bureau': [ + ('Fichier',[ + ('Nouveau','newJDC',''), + ('Ouvrir','openJDC',''), + ('Enregistrer','saveJDC',''), + ('Enregistrer sous','saveasJDC',''), + None, + ('Fermer','closeJDC',''), + ('Quitter','exitEFICAS',''), + ] + ), + ('Edition',[ + ('Copier','copy',''), + ('Couper','cut',''), + ('Coller','paste',''), + ] + ), + ('Jeu de commandes',[ + ('Rapport de validation','visuCRJDC',''), + ('Fichier à plat','visu_a_plat',''), + ('Fichier format v6','visuJDC_py'), + ('Fichier source','visu_txt_brut_JDC',''), + ('Paramètres Eficas','affichage_fichier_ini'), + ('Mots-clés inconnus','mc_inconnus'), + ] + ), + ('Aide',[ + ('Aide EFICAS','aideEFICAS',''), + ] + ), + ] + } diff --git a/Homard/properties.py b/Homard/properties.py index 5372e225..8ba0ed7e 100644 --- a/Homard/properties.py +++ b/Homard/properties.py @@ -1,3 +1,25 @@ # -*- coding: utf-8 -*- -version = "6.3.20" -date = "10/10/2002" +#@ MODIF properties Accas DATE 10/10/2002 AUTEUR gcbhhhh M.ADMINISTRATEUR +# CONFIGURATION MANAGEMENT OF EDF VERSION +# RESPONSABLE D6BHHHH J-P.LEFEBVRE +# ====================================================================== +# COPYRIGHT (C) 1991 - 2001 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. +# ====================================================================== +# IDENTIFICATION DU GESTIONNAIRE DE COMMANDE ACCAS A PARTIR +# DE LA VERSION DU CODE_ASTER ASSOCIE +#---------------------------------------------------------------------- +version = "7.1.0" +date = "23/04/2003" diff --git a/convert/convert_homard.py b/convert/convert_homard.py new file mode 100644 index 00000000..f03a6f0d --- /dev/null +++ b/convert/convert_homard.py @@ -0,0 +1,125 @@ +# -*- 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. +# +# 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. +# +# +# ====================================================================== +""" + Ce module contient le plugin convertisseur de fichier + au format python pour EFICAS. + + Un plugin convertisseur doit fournir deux attributs de classe : + extensions et formats et deux méthodes : readfile,convert. + + L'attribut de classe extensions est une liste d'extensions + de fichiers préconisées pour ce type de format. Cette information + est seulement indicative. + + L'attribut de classe formats est une liste de formats de sortie + supportés par le convertisseur. Les formats possibles sont : + eval, dict ou exec. + Le format eval est un texte source Python qui peut etre evalué. Le + résultat de l'évaluation est un objet Python quelconque. + Le format dict est un dictionnaire Python. + Le format exec est un texte source Python qui peut etre executé. + + La méthode readfile a pour fonction de lire un fichier dont le + nom est passé en argument de la fonction. + - convertisseur.readfile(nom_fichier) + + La méthode convert a pour fonction de convertir le fichier + préalablement lu dans un objet du format passé en argument. + - objet=convertisseur.convert(outformat) + + Ce convertisseur supporte le format de sortie exec + +""" +import sys,string,traceback + +import parseur_python +from Noyau import N_CR + +def entryPoint(): + """ + Retourne les informations nécessaires pour le chargeur de plugins + Ces informations sont retournées dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'homard', + # La factory pour créer une instance du plugin + 'factory' : PythonParser, + } + + +class PythonParser: + """ + Ce convertisseur lit un fichier au format python avec la + methode readfile : convertisseur.readfile(nom_fichier) + et retourne le texte au format outformat avec la + methode convertisseur.convert(outformat) + + Ses caractéristiques principales sont exposées dans 2 attributs + de classe : + - extensions : qui donne une liste d'extensions de fichier préconisées + - formats : qui donne une liste de formats de sortie supportés + """ + # Les extensions de fichier préconisées + extensions=('.py',) + # Les formats de sortie supportés (eval dict ou exec) + # Le format exec est du python executable (commande exec) converti avec PARSEUR_PYTHON + # Le format execnoparseur est du python executable (commande exec) non converti + formats=('exec','execnoparseur') + + def __init__(self,cr=None): + # Si l'objet compte-rendu n'est pas fourni, on utilise le + # compte-rendu standard + self.text='' + if cr : + self.cr=cr + else: + self.cr=N_CR.CR(debut='CR convertisseur format python', + fin='fin CR format python') + + def readfile(self,filename): + self.filename=filename + try: + self.text=open(filename).read() + except: + self.cr.fatal("Impossible ouvrir fichier %s" % filename) + return + + def convert(self,outformat): + if outformat == 'exec': + try: + return parseur_python.PARSEUR_PYTHON(self.text).get_texte() + except: + # Erreur lors de la conversion + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1], + sys.exc_info()[2]) + self.cr.exception("Impossible de convertir le fichier python \ + qui doit contenir des erreurs.\n \ + On retourne le fichier non converti \n \ + Prévenir la maintenance. \n" + string.join(l)) + # On retourne néanmoins le source initial non converti (au cas où) + return self.text + elif outformat == 'execnoparseur': + return self.text + else: + raise "Format de sortie : %s, non supporté" + return None + diff --git a/generator/generator_homard.py b/generator/generator_homard.py new file mode 100644 index 00000000..7e0770d6 --- /dev/null +++ b/generator/generator_homard.py @@ -0,0 +1,216 @@ +# 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. +# +# +# ====================================================================== +""" + Ce module contient le plugin generateur de fichier au format + homard pour EFICAS. + +""" +import traceback +import types,string,re + +from Noyau import N_CR +from Noyau.N_utils import repr_float +from Accas import ETAPE,PROC_ETAPE,MACRO_ETAPE,ETAPE_NIVEAU,JDC,FORM_ETAPE +from Accas import MCSIMP,MCFACT,MCBLOC,MCList,EVAL +from Accas import GEOM,ASSD,MCNUPLET +from Accas import COMMENTAIRE,PARAMETRE, PARAMETRE_EVAL,COMMANDE_COMM +from Formatage import Formatage +from generator_python import PythonGenerator + +def entryPoint(): + """ + Retourne les informations nécessaires pour le chargeur de plugins + + Ces informations sont retournées dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'homard', + # La factory pour créer une instance du plugin + 'factory' : HomardGenerator, + } + + +class HomardGenerator(PythonGenerator): + """ + Ce generateur parcourt un objet de type JDC et produit + un texte au format eficas et + un texte au format homard + + """ + # Les extensions de fichier préconisées + extensions=('.comm',) + + def __init__(self,cr=None): + # Si l'objet compte-rendu n'est pas fourni, on utilise le compte-rendu standard + if cr : + self.cr=cr + else: + self.cr=N_CR.CR(debut='CR generateur format homard pour homard', + fin='fin CR format homard pour homard') + # Le texte au format homard est stocké dans l'attribut text + self.dico_mot_clef={} + self.assoc={} + self.lmots_clef_calcules = ('SuivFron','TypeBila','ModeHOMA','CCAssoci', 'CCNoChaI','HOMaiN__','HOMaiNP1') + self.lmots_genea = ('NOM_MED_MAILLAGE_N','NOM_MED_MAILLAGE_NP1') +#,'COMPOSANTE','NUME_ORDRE','INST','PRECISION','CRITERE') + self.init_assoc() + self.text='' + self.textehomard=[] + + def init_assoc(self): + self.lmot_clef = ('CCMaiN__', 'CCNoMN__', 'CCIndica', 'CCSolN__', 'CCFronti', 'CCNoMFro', 'CCMaiNP1', + 'CCNoMNP1', 'CCSolNP1', 'TypeRaff', 'TypeDera', 'NiveauMa', 'SeuilHau', 'SeuilHRe', + 'SeuilHPE', 'NiveauMi', 'SeuilBas', 'SeuilBRe', 'SeuilBPE', 'ListeStd', 'NumeIter', + 'Langue ', 'CCGroFro', 'CCNoChaI', 'CCNumOrI', 'CCNumPTI', 'SuivFron', 'TypeBila', + 'ModeHOMA', 'HOMaiN__', 'HOMaiNP1') + +# Bizarre demander a Gerald : +# CVSolNP1 + self.assoc['CCMaiN__']='FICHIERS:NOM_MED_MAILLAGE_N' + self.assoc['CCNoMN__']='TRAITEMENT:NOM_MED_MAILLAGE_N' + self.assoc['CCIndica']='FICHIERS:NOM_MED_MAILLAGE_N' + self.assoc['CCSolN__']='FICHIERS:NOM_MED_MAILLAGE_N' + self.assoc['CCFronti']='FIC_FRON' + self.assoc['CCNoMFro']='NOM_MED_MAILLAGE_FRONTIERE' + self.assoc['CCMaiNP1']='FICHIERS:NOM_MED_MAILLAGE_NP1' + self.assoc['CCNoMNP1']='TRAITEMENT:NOM_MED_MAILLAGE_NP1' + self.assoc['CCSolNP1']='FICHIERS:NOM_MED_MAILLAGE_NP1' + self.assoc['TypeRaff']='RAFFINEMENT' + self.assoc['TypeDera']='DERAFFINEMENT' + self.assoc['NiveauMa']='NIVE_MAX' + self.assoc['SeuilHau']='CRIT_RAFF_ABS' + self.assoc['SeuilHRe']='CRIT_RAFF_REL' + self.assoc['SeuilHPE']='CRIT_RAFF_PE' + self.assoc['NiveauMi']='NIVE_MIN' + self.assoc['SeuilBas']='CRIT_DERA_ABS' + self.assoc['SeuilBRe']='CRIT_DERA_REL' + self.assoc['SeuilBPE']='CRIT_DERA_PE' + self.assoc['ListeStd']='INFORMATION' + self.assoc['NumeIter']='NITER' + self.assoc['Langue ']='LANGUE' + self.assoc['CCGroFro']='GROUP_MA' +# self.assoc['CCNoChaI']='NOM_MED' (on doit aussi ajouter 'COMPOSANTE') + self.assoc['CCNumOrI']='NUME_ORDRE' + self.assoc['CCNumPTI']='NUME_ORDRE' + + + def gener(self,obj,format='brut'): + self.text=PythonGenerator.gener(self,obj,format) + self.genereConfiguration() + return self.text + + def generMCSIMP(self,obj) : + """ + Convertit un objet MCSIMP en une liste de chaines de caractères à la + syntaxe homard + """ + s=PythonGenerator.generMCSIMP(self,obj) + if obj.nom in self.lmots_genea: + genea = obj.get_genealogie() + clef=genea[1]+":"+genea[-1] + else : + clef=obj.nom + self.dico_mot_clef[clef]=obj.val + return s + + def genereConfiguration(self): + ligbla=31*' ' + self.textehomard=[] + for mot in self.lmot_clef: + if mot not in self.lmots_clef_calcules : + clef_eficas=self.assoc[mot] + if self.dico_mot_clef.has_key(clef_eficas): + val=self.dico_mot_clef[clef_eficas] + if val != None: + try : + ligne=mot+' '+val + except: + ligne=mot+' '+repr(val) + ligne.rjust(32) + self.textehomard.append(ligne) + else: + val=apply(HomardGenerator.__dict__[mot],(self,)) + if val != None: + mot.rjust(8) + ligne=mot+' '+val + ligne.rjust(32) + self.textehomard.append(ligne) + + def get_homard(self): + return self.textehomard + + def SuivFron(self): + val="non" + if self.dico_mot_clef.has_key('NOM_MED_MAILLAGE_FRONTIERE'): + if self.dico_mot_clef['NOM_MED_MAILLAGE_FRONTIERE'] != None: + val="oui" + return val + + def TypeBila(self): + inttypeBilan = 1 + retour=None + dict_val={'NOMBRE':7,'INTERPENETRATION':3,'QUALITE':5,'CONNEXITE':11,'TAILLE':13} + for mot in ('NOMBRE','QUALITE','INTERPENETRATION','CONNEXITE','TAILLE'): + if self.dico_mot_clef.has_key(mot): + if (self.dico_mot_clef[mot] == "OUI"): + inttypeBilan=inttypeBilan*dict_val[mot] + retour = repr(inttypeBilan) + return retour + + + def ModeHOMA(self): + intModeHOMA=1 + if self.dico_mot_clef.has_key('INFORMATION'): + if self.dico_mot_clef['INFORMATION'] == "OUI": + intModeHOMA=2 + return repr(intModeHOMA) + + def CCAssoci(self): + return 'MED' + + def CCNoChaI(self): + if not (self.dico_mot_clef.has_key('NOM_MED')): + return None + if (self.dico_mot_clef['NOM_MED']== None): + return None + if not (self.dico_mot_clef.has_key('COMPOSANTE')): + return None + if (self.dico_mot_clef['COMPOSANTE']== None): + return None + chaine=self.dico_mot_clef['NOM_MED']+' '+self.dico_mot_clef['COMPOSANTE'] + return chaine + + def HOMaiN__(self): + chaine=None + if self.dico_mot_clef.has_key('NITER'): + if self.dico_mot_clef['NITER'] != None : + num="M"+repr(self.dico_mot_clef['NITER']) + chaine=num+" "+num+".hom" + return chaine + + def HOMaiNP1(self): + chaine=None + if self.dico_mot_clef.has_key('NITER'): + if self.dico_mot_clef['NITER'] != None : + num="M"+repr(self.dico_mot_clef['NITER']+1) + chaine=num+" "+num+".hom" + return chaine + -- 2.39.2