1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from Traducteur.parseur import FactNode
21 from Traducteur.load import jdcSet
26 dict_contexte_option={}
29 #--------------------------------------------------------------------------
30 def traitementRayon(jdc):
31 #--------------------------------------------------------------------------
33 if "DEFI_FONCTION" not in jdcSet : return
34 for c in jdc.root.childNodes:
35 if c.name != "DEFI_FONCTION" : continue
36 monTexte=jdc.getLines()[c.lineno-1]
37 monNomVariable=monTexte.split("=")[0]
38 aExecuter=monNomVariable+'=0'
39 dict_commande[monNomVariable]=c
40 exec aExecuter in dict_contexte
41 liste_MC=(("CALC_G","R_INF_FO"),("CALC_G","R_SUP_FO"),("CALC_G","MODULE_FO"))
42 liste_achanger = chercheValeurSelonGenea2 (jdc,liste_MC)
43 liste_MC=(("CALC_THETA","THETA_3D","R_INF_FO"),("CALC_THETA","THETA_3D","R_SUP_FO"),("CALC_THETA","THETA_3D","MODULE_FO"))
44 liste_achanger2 = chercheValeurSelonGenea3 (jdc,liste_MC)
45 liste_achanger=liste_achanger+liste_achanger2
46 for item in liste_achanger :
47 commande=dict_commande[item]
48 changeValeurABSCNiveau1(commande,jdc)
50 #----------------------------------
51 def changeValeurABSCNiveau1(c,jdc):
52 #----------------------------------
53 for child in c.childNodes:
54 if child.name != "NOM_PARA":continue
55 MonTexte=child.getText(jdc)
56 if len(MonTexte.splitlines()) > 1 :
57 print "Le Traducteur ne sait pas gerer"
59 MonTexte=jdc.getLines()[child.lineno-1]
60 debut=MonTexte.find("NOM_PARA")
61 debChaine=MonTexte[0:debut+8]
62 ancien=MonTexte[debut+8:]
63 egal,nomval,fin=ancien.split("'",2)
64 nouvelleLigne=debChaine+egal+"'ABSC'"+fin
65 jdc.getLines()[child.lineno-1]=nouvelleLigne
66 logging.info("renommage parametre ABSC ligne %d",child.lineno-1)
69 #--------------------------------------------------------------------------
70 def chercheValeurSelonGenea2(jdc,liste_cherche_valeur):
72 #--------------------------------------------------------------------------
74 for genea in liste_cherche_valeur:
77 print "la methode chercheValeurSelonGenea ne convient"
78 print "pas pour cette généalogie"
83 for c in jdc.root.childNodes:
84 if c.name != command:continue
85 for mc in c.childNodes:
86 if mc.name != fact:continue
87 MonTexte=mc.getText(jdc)
90 exec MonTexte in dict_contexte
91 monNomVar=MonTexte.split("=")[1]
94 while (monNomVar[i] == "," or monNomVar[i] == " ") :
95 monNomVarOk=monNomVar[0:i]
99 while (monNomVar[i] == " ") :
100 monNomVarOk=monNomVar[1:]
102 monNomVar=monNomVarOk
103 if monNomVar not in liste_valeurs : liste_valeurs.append(monNomVar)
106 logging.error("Pb pour renommer le parametre ABSC dans defi_fonctions selon calcg")
111 #--------------------------------------------------------------------------
112 def chercheValeurSelonGenea3(jdc,liste_cherche_valeur):
113 #--------------------------------------------------------------------------
115 for genea in liste_cherche_valeur:
116 profondeur=len(genea)
118 print "la methode chercheValeurSelonGenea ne convient"
119 print "pas pour cette généalogie"
125 for c in jdc.root.childNodes:
126 if c.name != command : continue
127 for mcf in c.childNodes:
128 if mcf.name != fact : continue
131 for lc in ll.childNodes:
132 if lc.name !=mc : continue
133 MonTexte=lc.getText(jdc)
136 exec MonTexte in dict_contexte
137 #monNomVar=MonTexte.split("=")[1][0:-1]
138 monNomVar=MonTexte.split("=")[1]
139 monNomVarOk=monNomVar
141 while (monNomVar[i] == "," or monNomVar[i] == " ") :
142 monNomVarOk=monNomVar[0:i]
144 monNomVar=monNomVarOk
146 while (monNomVar[i] == " ") :
147 monNomVarOk=monNomVar[1:]
149 monNomVar=monNomVarOk
150 if monNomVar not in liste_valeurs : liste_valeurs.append(monNomVar)
153 logging.error("Pb pour renommer le parametre ABSC dans defi_fonctions selon calcg")