Salome HOME
Merge branch 'V9_2_2_BR'
[tools/yacsgen.git] / module_generator / gener.py
index 757ebc6b3fa7b598ff462e1ff7c37988d5ff3544..6b6dc1c47217c4aac4fe5bb5e664a4dabdbb927a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2016  EDF R&D
+# Copyright (C) 2009-2019  EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -294,7 +294,7 @@ class Service(object):
 
       >>> s1 = module_generator.Service('myservice', inport=[("a","double"),],
                                         instream=[("aa","CALCIUM_double","I")],
-                                        body="print a")
+                                        body="print( a)")
 
 
   """
@@ -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)