소스 검색

using io.open instead of open to have the encoding parameter available on python 2.7, too.

Holger Jeromin 9 년 전
부모
커밋
6d8a59eac5
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      tools/amalgamate.py

+ 5 - 4
tools/amalgamate.py

@@ -2,6 +2,7 @@ from __future__ import print_function
 import re
 import argparse
 import os.path
+import io
 
 parser = argparse.ArgumentParser()
 parser.add_argument('version', help='version to include')
@@ -25,7 +26,7 @@ for fname in args.inputs:
     if("util.h" in fname):
         is_c = True
         continue
-    with open(fname, encoding="utf8") as infile:
+    with io.open(fname, encoding="utf8") as infile:
         print ("Integrating file '" + fname + "'...", end=""),
         for line in infile:
             res = include_re.match(line)
@@ -35,7 +36,7 @@ for fname in args.inputs:
                     includes.append(inc)
         print ("done."),
 
-file = open(args.outfile, 'w')
+file = io.open(args.outfile, 'w')
 file.write('''/* THIS IS A SINGLE-FILE DISTRIBUTION CONCATENATED FROM THE OPEN62541 SOURCES 
  * visit http://open62541.org/ for information about this software
  * Git-Revision: %s
@@ -74,7 +75,7 @@ else:
 #endif\n\n''')
     for fname in args.inputs:
         if "ua_config.h" in fname or "ua_util.h" in fname:
-            with open(fname, encoding="utf8") as infile:
+            with io.open(fname, encoding="utf8") as infile:
                 print ("Integrating file '" + fname + "'...", end=""),
                 for line in infile:
                     file.write(line)
@@ -83,7 +84,7 @@ else:
 
 for fname in args.inputs:
     if not "util.h" in fname:
-        with open(fname, encoding="utf8") as infile:
+        with io.open(fname, encoding="utf8") as infile:
             file.write("/*********************************** amalgamated original file \"" + fname + "\" ***********************************/\n")
             print ("Integrating file '" + fname + "'...", end=""),
             for line in infile: