Salome HOME
Porting Case tools to Python3
authorabn <adrien.bruneton@cea.fr>
Mon, 27 Aug 2018 11:33:24 +0000 (13:33 +0200)
committerabn <adrien.bruneton@cea.fr>
Mon, 27 Aug 2018 11:33:24 +0000 (13:33 +0200)
src/MEDLoader/Swig/CaseIO.py
src/MEDLoader/Swig/CaseWriter.py
src/MEDLoader/Swig/case2med
src/MEDLoader/Swig/med2case

index fa61441de3362338b222195ad94e54dc5db828c6..986a408a0268a1b59a5294b2c8b4053db69e7ff9 100644 (file)
@@ -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
index c5d2bf4b888b64b0483dfc9f3a6f763a3d05e003..438e5cd1337458b1e6b5dfa09ba9f9bcd547a8eb 100644 (file)
@@ -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)
index 9dd448501a7e2719c4c7ab485da64dd2a27623fa..cd32417cc7dfd9ec3339bebe7dbd49353f1cfa45 100755 (executable)
@@ -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))
     
index b7ff919e5b077b55a0133c2b96890af630a6e62a..6f6400b7b90811930437ef20d57df8d5326c90e0 100755 (executable)
@@ -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("#########")