From 5551546f09e376bbf78d05a117f614f636caad5e Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 27 Aug 2018 13:33:24 +0200 Subject: [PATCH] Porting Case tools to Python3 --- src/MEDLoader/Swig/CaseIO.py | 6 +++--- src/MEDLoader/Swig/CaseWriter.py | 8 ++++---- src/MEDLoader/Swig/case2med | 6 +++--- src/MEDLoader/Swig/med2case | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/MEDLoader/Swig/CaseIO.py b/src/MEDLoader/Swig/CaseIO.py index fa61441de..986a408a0 100644 --- a/src/MEDLoader/Swig/CaseIO.py +++ b/src/MEDLoader/Swig/CaseIO.py @@ -25,7 +25,7 @@ class CaseIO: dictMCTyp={NORM_HEXA8:"hexa8",NORM_POLYHED:"nfaced",NORM_QUAD4:"quad4",NORM_POLYGON:"nsided",NORM_POINT1:"point",NORM_SEG2:"bar2",NORM_SEG3:"bar3",NORM_TRI3:"tria3",NORM_TRI6:"tria6",NORM_QUAD8:"quad8",NORM_TETRA4:"tetra4",NORM_TETRA10:"tetra10",NORM_PYRA5:"pyramid5",NORM_PYRA13:"pyramid13",NORM_PENTA6:"penta6",NORM_PENTA15:"penta15",NORM_HEXA20:"hexa20"} discSpatial={ON_CELLS:"element",ON_NODES:"node"} dictCompo={1:"scalar",3:"vector",6:"tensor",9:"tensor9"} - dictMCTyp2 = {v:k for k, v in dictMCTyp.items()} - discSpatial2 = {v:k for k, v in discSpatial.items()} - dictCompo2 = {v:k for k, v in dictCompo.items()} + dictMCTyp2 = {v:k for k, v in list(dictMCTyp.items())} + discSpatial2 = {v:k for k, v in list(discSpatial.items())} + dictCompo2 = {v:k for k, v in list(dictCompo.items())} pass diff --git a/src/MEDLoader/Swig/CaseWriter.py b/src/MEDLoader/Swig/CaseWriter.py index c5d2bf4b8..438e5cd13 100644 --- a/src/MEDLoader/Swig/CaseWriter.py +++ b/src/MEDLoader/Swig/CaseWriter.py @@ -201,7 +201,7 @@ time values: self._ze_top_dict={} its,areForgottenTS=mdfs.getCommonIterations() if areForgottenTS: - print("WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its))) + print(("WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its)))) pass TimeValues="" for it in its: @@ -213,10 +213,10 @@ time values: if nbCompo not in self.dictCompo: l = [x for x in self.dictCompo if x - nbCompo > 0] if len(l)==0: - print("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys())))) + print(("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys()))))) continue pass - print("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys())))) + print(("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys()))))) nbCompo=l[0] pass if nbCompo in dictVars: @@ -276,7 +276,7 @@ time values: mm.write(self.__str80("coordinates")) pass else: - print("UnManaged type of field for field \"%s\" !"%(mdf.getName())) + print(("UnManaged type of field for field \"%s\" !"%(mdf.getName()))) pass a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg)) b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg) diff --git a/src/MEDLoader/Swig/case2med b/src/MEDLoader/Swig/case2med index 9dd448501..cd32417cc 100755 --- a/src/MEDLoader/Swig/case2med +++ b/src/MEDLoader/Swig/case2med @@ -46,9 +46,9 @@ cr=CaseReader(fname) try: medfd=cr.loadInMEDFileDS() except: - print "An error occurred during the conversion!" - print "#######################################" + print("An error occurred during the conversion!") + print("#######################################") raise medfd.write(fOut,2) -print "#########\nFile \"%s\" written !\n#########"%(fOut) +print("#########\nFile \"%s\" written !\n#########"%(fOut)) diff --git a/src/MEDLoader/Swig/med2case b/src/MEDLoader/Swig/med2case index b7ff919e5..6f6400b7b 100755 --- a/src/MEDLoader/Swig/med2case +++ b/src/MEDLoader/Swig/med2case @@ -53,11 +53,11 @@ try: cw.setMEDFileDS(mfd) listOfWrittenFileNames=cw.write(fOut) except InterpKernelException as e: - print "An error occurred during the conversion!" - print "#######################################" + print("An error occurred during the conversion!") + print("#######################################") raise e -print "#########" +print("#########") for l in listOfWrittenFileNames: - print "File \"%s\" successfully written !"%(l) + print("File \"%s\" successfully written !"%(l)) pass -print "#########" +print("#########") -- 2.39.2