Salome HOME
Further fix for CaseReader Py3 ...
[tools/medcoupling.git] / src / MEDLoader / Swig / CaseWriter.py
index c5d2bf4b888b64b0483dfc9f3a6f763a3d05e003..c8f4f74a3e368d0b2876a2acf529da645f17b179 100644 (file)
@@ -158,7 +158,7 @@ time values:
                         typ=MEDCouplingMesh.GetCorrespondingPolyType(typ)
                         pass
                     mp=m[i:i+nbelem]
-                    mm.write(self.__str80(self.dictMCTyp[typ]))
+                    mm.write(self.__str80(self.dictMCTyp_str[typ]))
                     a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
                     a[0]=nbelem ; a.flush() ; mm.seek(mm.tell()+4)
                     if typ!=NORM_POLYHED and typ!=NORM_POLYGON:
@@ -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:
@@ -270,13 +270,13 @@ time values:
                         if typ==curTyp:
                             arr=ff.getUndergroundDataArray()[bg:end].changeNbOfComponents(nbCompo,0.) ; arr=arr.toNoInterlace()
                             if typ==ON_CELLS:
-                                mm.write(self.__str80(self.dictMCTyp[geo]))
+                                mm.write(self.__str80(self.dictMCTyp_str[geo]))
                                 pass
                             elif typ==ON_NODES:
                                 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)
@@ -319,7 +319,7 @@ time values:
     def __str80(cls,st):
         if len(st)>79:
             raise Exception("String \"%s\" is too long (>79) !"%(st))
-        return st.ljust(79)+"\n"
+        return bytes(str(st).ljust(79)+"\n", "ascii")
 
     def __computeSizeOfGeoFile(self,listOfMeshes,nn):
         sz=0