]> SALOME platform Git repositories - tools/yacsgen.git/commitdiff
Salome HOME
Small fix for Python3
authorNicolas Geimer <nicolas.geimer@edf.fr>
Tue, 1 Aug 2017 08:23:40 +0000 (10:23 +0200)
committerNicolas Geimer <nicolas.geimer@edf.fr>
Tue, 1 Aug 2017 08:23:40 +0000 (10:23 +0200)
module_generator/gener.py

index 757ebc6b3fa7b598ff462e1ff7c37988d5ff3544..e32442ff101b64007800b4ad2737cc7eefb06d91 100644 (file)
@@ -811,13 +811,10 @@ ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR})
     """
     for name, content in list(dic.items()):
       filename = os.path.join(basedir, name)
-      if isinstance(content, basestring):
-        if isinstance(content, unicode):
-            # encodage to utf-8 if unicode string
-            content=content.encode('utf8')
-        fil =  open(filename, 'w')
-        fil.write(content)
-        fil.close()
+      if isinstance(content, str):
+        # encodage to utf-8 if unicode string / on python3 str are unicode
+        with open(filename, 'w') as fil:
+          fil.write(content)
       else:
         if not os.path.exists(filename):
           os.makedirs(filename)