#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-import re, string
+from __future__ import absolute_import
+
+
+import re
from Extensions.i18n import tr
-from convert_python import PythonParser
+from .convert_python import PythonParser
+import six
+from six.moves import range
+try:
+ basestring
+except NameError:
+ basestring = str
pattern_comment_slash = re.compile(r"^\s*/")
pattern_eta = re.compile(r".*&ETA.*")
from Extensions import localisation
-from determine import monEnvQT5
-
def entryPoint():
Return a dictionary containing the description needed to load the plugin
"""
return {
- 'name' : 'TELEMAC3',
+ 'name' : 'TELEMAC',
'factory' : TELEMACParser
}
if appli.langue=='fr' :
from enumDicoTelemac import DicoEnumCasFrToEnumCasEn
- for k in DicoEnumCasFrToEnumCasEn.keys() :
+ for k in DicoEnumCasFrToEnumCasEn :
TelemacdicoEn[k]=DicoEnumCasFrToEnumCasEn[k]
text=""
self.dictSimp={}
- l_lignes_texte_all = string.split(self.text,'\n')
+ l_lignes_texte_all = self.text.split('\n')
l_lignes_texte = []
for l in l_lignes_texte_all :
if not(pattern_comment_slash.match(l)): l_lignes_texte.append(l)
m=pattern_ligne.match(finLigne)
if m == None :
- #print "________________________________________________"
- print 'pb avec ****', finLigne , '**** dans ', ligne
- #print "________________________________________________"
+ #print( "________________________________________________")
+ print ('pb avec ****', finLigne , '**** dans ', ligne)
+ #print( "________________________________________________")
break
simpCas=self.traiteIdent(m.group('ident'))
elif pattern_texteSimple.match(finLigne):
m=pattern_texteSimple.match(finLigne)
else :
- #print "________________________________________________"
- print 'pb avec ****', finLigne , '**** dans ', ligne
- print "non match"
- #print "________________________________________________"
+ #print ("________________________________________________")
+ print ('pb avec ****', finLigne , '**** dans ', ligne)
+ print ("non match")
+ #print ("________________________________________________")
break
finLigne=m.group('reste')
self.dictSimp[simpCas]=valeur
- #print self.dictSimp
- if 'TITLE' not in self.dictSimp.keys() :
+ if 'TITLE' not in self.dictSimp :
import os
#self.dictSimp['TITLE']=os.path.basename(self.filename)
dicoParMC={}
- for simp in self.dictSimp.keys():
- if simp in TELEMACParser.__dict__.keys() : apply(TELEMACParser.__dict__[simp],(self,))
+ for simp in self.dictSimp:
+ if simp in TELEMACParser.__dict__ : TELEMACParser.__dict__[simp],(self,)
- for simp in self.dictSimp.keys():
+ for simp in self.dictSimp:
if simp in ListeSupprimeCasToEficas: continue
- if simp not in self.dicoInverse.keys() :
- #print "************"
- print "pb avec dans dicoInverse", simp,'------'
- #print "************"
- #print poum
+ if simp not in self.dicoInverse :
+ #print ( "************")
+ print ("pb avec dans dicoInverse", simp,'------')
+ #print ("************")
continue
listeGenea=self.dicoInverse[simp]
listeGeneaReverse=[]
listeGeneaReverse.reverse()
dicoTravail=dicoParMC
i=0
- #print (listeGeneaReverse[0:-1])
while i < len(listeGeneaReverse[0:-1]) :
mot=listeGeneaReverse[i]
i=i+1
- if mot not in dicoTravail.keys(): dicoTravail[mot]={}
+ if mot not in dicoTravail: dicoTravail[mot]={}
dicoTravail=dicoTravail[mot]
dicoTravail[simp]=self.dictSimp[simp]
self.textePy=""
- #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
- #print dicoParMC
- #print "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
- listeMC=self.tri(dicoParMC.keys())
+ listeMC=self.tri(list(dicoParMC.keys()))
for k in listeMC :
- #print "----------- traitement de " , k
self.textePy += str(k )+ "("
self.traiteMC(dicoParMC[k])
self.textePy += ");\n"
- #print "----------- "
- appli.listeTelemac=self.dictSimp.keys()
+ appli.listeTelemac=self.dictSimp
return self.textePy
# enleve les espaces de part et autre
# traduit du langage Telemac vers le langage Catalogue
#----------------------------------------
- #print ident
while ident[-1] == " " or ident[-1] == '\t' : ident=ident[0:-1]
while ident[0] == " " or ident[0] == '\t' : ident=ident[1:]
try : identCata=self.dicoCasToCata[ident]
except :
- print "---> ", "pb mot clef pour", ident
+ print ( "---> ", "pb mot clef pour", ident)
identCata=None
return identCata
def traiteMC(self,dico) :
from Accas import A_BLOC, A_FACT, A_SIMP
- for k in dico.keys() :
+ for k in dico :
valeur= dico[k]
- if k not in self.dicoMC.keys() : kA=self.dicoFrancaisAnglais[k]
+ if k not in self.dicoMC : kA=self.dicoFrancaisAnglais[k]
else : kA=k
obj=self.dicoMC[kA]
if isinstance(obj,A_FACT.FACT): self.convertFACT(obj,kA,valeur)
elif isinstance(obj,A_BLOC.BLOC): self.convertBLOC(obj,kA,valeur)
elif isinstance(obj,A_SIMP.SIMP): self.convertSIMP(obj,kA,valeur)
- else : print "%%%%%%%%%%%\n", "pb conversion type pour", k, obj, "\n%%%%%%%%%%%"
+ else : print ("%%%%%%%%%%%\n", "pb conversion type pour", k, obj, "\n%%%%%%%%%%%")
- #print "_____________"
def convertFACT(self,obj,nom,valeur):
- #print "convertFACT", nom,valeur
- if nom in TELEMACParser.__dict__.keys() :
- apply(TELEMACParser.__dict__[nom],(self,))
+ if nom in TELEMACParser.__dict__ :
+ TELEMACParser.__dict__[nom],(self,)
return
self.textePy += nom + "=_F( "
self.traiteMC(valeur)
def convertBLOC(self,obj,nom,valeur):
- print "BLOC "
- print nom
+ print ("ANOMALIE _________ BLOC ")
+ print (nom)
def convertSIMP(self,obj,nom,valeur):
#print 'in convertSIMP', nom,valeur
try : valeur=eval(valeur,{})
except : pass
- if nom in TelemacdicoEn.keys():
+ if nom in TelemacdicoEn:
try :
valeur=TelemacdicoEn[nom][valeur]
self.textePy += nom + "= '" + str(valeur) +"',"
break
except:
if valeur != None :
- print "pb avec le type de ", obj.nom, obj.type, 'et la valeur ', valeur
+ print ("pb avec le type de ", obj.nom, obj.type, 'et la valeur ', valeur)
if 'Fichier' in obj.type or 'TXM' in obj.type or 'Repertoire' in obj.type :
valeur=str(valeur)
# Attention : on attend une liste mais on a une seule valeur!
try : oldValeur=eval(oldValeur,{})
except : pass
- if nom in TelemacdicoEn.keys() :
+ if nom in TelemacdicoEn :
v=TelemacdicoEn[nom][oldValeur]
self.textePy += nom + "= ('" + str(v) +"',),"
else :
for v in valeur :
try : v=eval(v,{})
except : pass
- if nom in TelemacdicoEn.keys():
- #print "est dans le dico des enum, valeurs multiples"
+ if nom in TelemacdicoEn:
try : v=TelemacdicoEn[nom][v]
except : pass
newVal.append(v)
def tri(self, listeIn):
if len(listeIn) == 1 : return listeIn
if self.Ordre_Des_Commandes == None : return listeIn
- #print listeIn
listeOut=[listeIn[0],]
for k in listeIn[1:]:
#k=str(self.dicoFrancaisAnglais[kF])
return listeOut
def LIQUID_BOUNDARIES(self):
- print 'Liquid Boundaries'
texte_Boundaries="LIQUID_BOUNDARIES=( "
- if 'PRESCRIBED_ELEVATIONS' in self.dictSimp.keys():
+ if 'PRESCRIBED_ELEVATIONS' in self.dictSimp:
valeursPE=self.dictSimp["PRESCRIBED_ELEVATIONS"]
if not type(valeursPE)==list : valeursPE = (valeursPE,)
longueur=len(self.dictSimp["PRESCRIBED_ELEVATIONS"])
else : valeursPE=None
- if 'PRESCRIBED_FLOWRATES' in self.dictSimp.keys():
+ if 'PRESCRIBED_FLOWRATES' in self.dictSimp:
valeursPF=self.dictSimp["PRESCRIBED_FLOWRATES"]
if not type(valeursPF)==list : valeursPF = (valeursPF,)
longueur=len(self.dictSimp["PRESCRIBED_FLOWRATES"])
else : valeursPF=None
- if 'PRESCRIBED_VELOCITIES' in self.dictSimp.keys():
+ if 'PRESCRIBED_VELOCITIES' in self.dictSimp:
valeursPV=self.dictSimp["PRESCRIBED_VELOCITIES"]
if not type(valeursPV)==list : valeursPV = (valeursPV,)
longueur=len(self.dictSimp["PRESCRIBED_VELOCITIES"])
if valeursPF == None : valeursPF = listNulle
if valeursPV == None : valeursPV = listNulle
- #print valeursPE,valeursPF,valeursPV
for e in range(len(valeursPE)):
if valeursPE[e] != "" or valeursPE[e] != "\n" :
texte_Boundaries += "_F( BOUNDARY_TYPE= 'Prescribed Velocity',\n"
texte_Boundaries += "PRESCRIBED_VELOCITIES = " + str(valeursPV[e]) + "),\n"
continue
- print "pb texte_Boundaries avec la valeur numero ", e
+ print ("pb texte_Boundaries avec la valeur numero ", e)
texte_Boundaries +="),\n"
self.textePy += texte_Boundaries