- """
- This converter works like Pythonparser, except that it also initializes all
- model variables to None in order to avoid Python syntax errors when loading
- a file with a different or inexistent definition of variables.
- """
-
-
-
- def convert(self, outformat, appliEficas=None):
-
-
- from Accas import A_BLOC, A_FACT, A_SIMP
- try :
- self.dicoCasToCata = appliEficas.readercata.dicoCasToCata
- except :
- self.dicoCasToCata = {}
- print ('pas de dicoCasToCata')
- self.dicoInverse = appliEficas.readercata.dicoInverse
- self.dicoMC = appliEficas.readercata.dicoMC
- self.Ordre_Des_Commandes = appliEficas.readercata.Ordre_Des_Commandes
- try :
- self.TelemacdicoEn = appliEficas.readercata.TelemacdicoEn
- except :
- self.TelemacdicoEn = {}
- print ('pas de TelemacdicoEn')
- try :
- self.DicoEnumCasFrToEnumCasEn = appliEficas.readercata.DicoEnumCasFrToEnumCasEn
- except :
- self.DicoEnumCasFrToEnumCasEn = {}
- print ('pas de DicoEnumCasFrToEnumCasEn')
-
-
- if appliEficas.langue=='fr' :
- #from enum_Telemac2d_auto import DicoEnumCasFrToEnumCasEn
- for k in self.DicoEnumCasFrToEnumCasEn :
- self.TelemacdicoEn[k]=self.DicoEnumCasFrToEnumCasEn[k]
-
- text=""
- self.dictSimp={}
-
- l_lignes_texte_all = self.text.split('\n')
- l_lignes_texte = []
- listeComment = []
- dicoComment={}
- dicoCommentSimp={}
- dicoCommentMC={}
- texteComment=""
- debut=True
- trouveComment = 0
- for l in l_lignes_texte_all :
- if pattern_eta.match(l) : continue
- if pattern_fin.match(l) : continue
- if pattern_blanc.match(l) : continue
-
- if not(pattern_comment_slash.match(l)):
- l_lignes_texte.append(l)
- if trouveComment :
- if debut: dicoComment['debut']=texteComment
- else : dicoComment[l]=texteComment
- trouveComment = 0
- texteComment=""
- if debut : debut = False
-
- if pattern_comment_slash.match(l):
- #if pattern_comment_slash_vide.match(l) : continue
- if pattern_comment_tiret.match(l) : continue
- texteComment+=l.replace ('/','',1)
- texteComment+='\n'
- trouveComment=1
-
- if texteComment != "" : dicoComment['fin']= texteComment
-
-
- l_lignes=[]
- i=0
- while (i < len(l_lignes_texte)) :
- ligne=l_lignes_texte[i]
- i=i+1
- if not(pattern_finit_par_virgule_ou_affect.match(ligne)):
- l_lignes.append(ligne)
- continue
- nouvelle_ligne=ligne
- while (i < len(l_lignes_texte)):
- ligne_traitee=l_lignes_texte[i]
- i=i+1
- nouvelle_ligne += ligne_traitee
- if not(pattern_finit_par_virgule_ou_affect.match(ligne_traitee)):
- l_lignes.append(nouvelle_ligne)
- break
-
-
- for ligne in l_lignes :
- if pattern_comment_slash.match(ligne) : continue
- #PN : deja teste
- #if pattern_eta.match(ligne) : continue
- #if pattern_fin.match(ligne) : continue
- #if pattern_blanc.match(ligne) : continue
-
-
- finLigne=ligne
- while finLigne != "" :
- if pattern_comment_slash.match(finLigne) : finLigne=""; continue
- valeur=""
- if pattern_variables.match(finLigne) :
- m=pattern_variables.match(finLigne)
- simpCas=self.traiteIdent(m.group('ident'))
- valeur=m.group('valeur')
- finLigne=m.group('reste')
- self.dictSimp[simpCas]=valeur
- continue
-
-
- m=pattern_ligne.match(finLigne)
- if m == None :
- #print( "________________________________________________")
- print ('pb avec ****', finLigne , '**** dans ', ligne)
- #print( "________________________________________________")
- break
-
- simpCas=self.traiteIdent(m.group('ident'))
- if not simpCas :
- finLigne=m.group('reste')
- continue
-
- finLigne=m.group('reste')
- # attention, l ordre des if est important
- if pattern_liste.match(finLigne) :
- m=pattern_liste.match(finLigne)
- elif pattern_liste_texte.match(finLigne) :
- m=pattern_liste_texte.match(finLigne)
- elif pattern_texteQuote.match(finLigne) :
- m=pattern_texteQuote.match(finLigne)
- elif pattern_flottant.match(finLigne) :
- m=pattern_flottant.match(finLigne)
- elif pattern_texteVide.match(finLigne):
- m=pattern_texteVide.match(finLigne)
- elif pattern_texteSimple.match(finLigne):
- m=pattern_texteSimple.match(finLigne)
- else :
- #print ("________________________________________________")
- print ('pb avec ****', finLigne , '**** dans ', ligne)
- print ("non match")
- #print ("________________________________________________")
- break
-
-
- valeur=m.group('valeur')
- if pattern_blanc.match(valeur) : valeur=None
-
- if pattern_flottant.match(finLigne) :
- valeur=re.sub("d","e",valeur)
- valeur=re.sub("D","E",valeur)
-
- if pattern_liste.match(finLigne) or pattern_liste_texte.match(finLigne):
- valeur=valeur.split(";")
-
-
- finLigne=m.group('reste')
- self.dictSimp[simpCas]=valeur
-
- if ligne in dicoComment.keys():
- dicoCommentSimp[simpCas]=dicoComment[ligne]
-
- if 'TITLE' not in self.dictSimp :
- import os
- #self.dictSimp['TITLE']=os.path.basename(self.filename)
-
-
- dicoParMC={}
- for simp in self.dictSimp:
- if simp in TELEMACparser.__dict__ : TELEMACparser.__dict__[simp](self,)
-
- for simp in self.dictSimp:
- if simp not in self.dicoInverse :
- #print ( "************")
- print ("pb avec dans dicoInverse", simp,'------')
- print("dicoInverse",sorted(self.dicoInverse.keys()))
- #print ("************")
- continue
- listeGenea=self.dicoInverse[simp]
- listeGeneaReverse=[]
- for (u,v) in listeGenea :
- if isinstance(v,A_BLOC.BLOC): continue
- listeGeneaReverse.append(u)
- listeGeneaReverse.reverse()
- dicoTravail=dicoParMC
- i=0
- if simp in dicoCommentSimp :
- MC=listeGeneaReverse[0]
- if MC in dicoCommentMC : dicoCommentMC[MC]+dicoCommentSimp[simp]
- else : dicoCommentMC[MC]=dicoCommentSimp[simp]
- while i < len(listeGeneaReverse[0:-1]) :
- mot=listeGeneaReverse[i]
+ """
+ This converter works like Pythonparser, except that it also initializes all
+ model variables to None in order to avoid Python syntax errors when loading
+ a file with a different or inexistent definition of variables.
+ """
+
+
+
+ def convert(self, outformat, appliEficas=None):
+
+
+ from Accas import A_BLOC, A_FACT, A_SIMP
+ try :
+ self.dicoCasToCata = appliEficas.readercata.dicoCasToCata
+ except :
+ self.dicoCasToCata = {}
+ print ('pas de dicoCasToCata')
+ self.dicoInverse = appliEficas.readercata.dicoInverse
+ self.dicoMC = appliEficas.readercata.dicoMC
+ self.Ordre_Des_Commandes = appliEficas.readercata.Ordre_Des_Commandes
+ try :
+ self.TelemacdicoEn = appliEficas.readercata.TelemacdicoEn
+ except :
+ self.TelemacdicoEn = {}
+ print ('pas de TelemacdicoEn')
+ try :
+ self.DicoEnumCasFrToEnumCasEn = appliEficas.readercata.DicoEnumCasFrToEnumCasEn
+ except :
+ self.DicoEnumCasFrToEnumCasEn = {}
+ print ('pas de DicoEnumCasFrToEnumCasEn')
+
+
+ if appliEficas.langue=='fr' :
+ #from enum_Telemac2d_auto import DicoEnumCasFrToEnumCasEn
+ for k in self.DicoEnumCasFrToEnumCasEn :
+ self.TelemacdicoEn[k]=self.DicoEnumCasFrToEnumCasEn[k]
+
+ text=""
+ self.dictSimp={}
+
+ l_lignes_texte_all = self.text.split('\n')
+ l_lignes_texte = []
+ listeComment = []
+ dicoComment={}
+ dicoCommentSimp={}
+ dicoCommentMC={}
+ texteComment=""
+ debut=True
+ trouveComment = 0
+ for l in l_lignes_texte_all :
+ if pattern_eta.match(l) : continue
+ if pattern_fin.match(l) : continue
+ if pattern_blanc.match(l) : continue
+
+ if not(pattern_comment_slash.match(l)):
+ l_lignes_texte.append(l)
+ if trouveComment :
+ if debut: dicoComment['debut']=texteComment
+ else : dicoComment[l]=texteComment
+ trouveComment = 0
+ texteComment=""
+ if debut : debut = False
+
+ if pattern_comment_slash.match(l):
+ #if pattern_comment_slash_vide.match(l) : continue
+ if pattern_comment_tiret.match(l) : continue
+ texteComment+=l.replace ('/','',1)
+ texteComment+='\n'
+ trouveComment=1
+
+ if texteComment != "" : dicoComment['fin']= texteComment
+
+
+ l_lignes=[]
+ i=0
+ while (i < len(l_lignes_texte)) :
+ ligne=l_lignes_texte[i]