]> SALOME platform Git repositories - tools/eficas.git/blob - Editeur/eficas_test.py
Salome HOME
pour tenir compte de LASSD
[tools/eficas.git] / Editeur / eficas_test.py
1 # -*- coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21 """
22     Ce module permet de lancer l'application EFICAS en affichant
23     un ecran Splash pour faire patentier l'utilisateur
24 """
25 # Modules Python
26 import sys
27 import Tkinter
28
29 # Modules Eficas
30 import import_code
31 import session
32
33 def lance_eficas(code,fichier=None):
34     """
35         Lance l'appli EFICAS
36     """
37     options=session.parse(sys.argv)
38     root = Tkinter.Tk()
39     import eficas
40     if fichier :
41         a=eficas.EFICAS(root,code=code,fichier = fichier,test=1)
42         bureau=a.getBureau()
43     else:
44         eficas.EFICAS(root,code=code)
45
46     print bureau.JDC.report()
47     bureau.closeJDC()
48
49 def duplique_fichier(code,fichier=None,root=None):
50     print code
51     print fichier
52     if root == None :
53        root = Tkinter.Tk()
54     import eficas
55     import convert
56     import generator
57     import utils
58     import string
59
60     from Editeur import session
61     if fichier != None :
62        options=session.parse(sys.argv+[fichier])
63     else :
64        options=session.parse(sys.argv)
65
66     appli=eficas.EFICAS(root,code=code,fichier = fichier,test=1)
67     format='homard'
68     if convert.plugins.has_key(format):
69        p=convert.plugins[format]()
70        p.readfile(fichier)
71        text=p.convert('exec',appli)
72        print text
73        text2=convertir(text)
74        print text2
75        cata=appli.readercata.cata
76        J=cata[0].JdC(procedure=text2,cata=cata)
77        J.analyse()
78        fileName=fichier+"_init"
79        if generator.plugins.has_key(format):
80           g=generator.plugins[format]()
81           jdc_formate=g.gener(J,format='beautifie')
82           print "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
83           print jdc_formate
84           jdc_fini = string.replace(jdc_formate,'\r\n','\n')
85           print jdc_fini
86           utils.save_in_file(fileName+".comm",jdc_fini,None)
87
88 def convertir(texte):
89     import re
90     dict_change={"FICHIER_MED_MAILLAGE_N=":"FICHIER_MED_MAILLAGE_NP1","NOM_MED_MAILLAGE_N=":"NOM_MED_MAILLAGE_NP1"}
91     for mot in dict_change.keys():
92         if( re.search(mot,texte)):
93           indicenouveau=re.search(mot,texte).end()
94           indicefinnouveau= texte.find(",",indicenouveau)
95           avant=dict_change[mot]
96           if( re.search(avant,texte)):
97              indiceancien=re.search(avant,texte).end()+1
98              indicefinancien= texte.find(",",indiceancien)
99              valeur=texte[indiceancien:indicefinancien]
100              texte=texte[0:indicenouveau]+valeur+texte[indicefinnouveau:]
101     liste_mot_clef_None=['CRIT_RAFF_ABS','CRIT_RAFF_REL','CRIT_RAFF_PE','CRIT_DERA_ABS','CRIT_DERA_REL','CRIT_DERA_PE','NITER','NOM_MED_MAILLAGE_NP1','FICHIER_MED_MAILLAGE_NP1']
102
103     for mot in liste_mot_clef_None:
104         if( re.search(mot,texte)):
105            indice=re.search(mot,texte).end()+1
106            indicefin= texte.find(",",indice)
107            texte=texte[0:indice]+"None"+texte[indicefin:]
108     return texte
109