Stefan Profanter лет назад: 6
Родитель
Сommit
7a4996743a

+ 2 - 1
tools/nodeset_compiler/backend_graphviz.py

@@ -1,5 +1,6 @@
 from nodeset import *
 import graphviz as gv
+import codecs
 
 def nodePrintDot(node):
     cleanname = "node_" + str(node.id).replace(";", "").replace("=", "")
@@ -39,7 +40,7 @@ def printDotGraphWalk(nodeset, depth=1, filename="out.dot", rootNode=None,
     else:
         root = rootNode
 
-    file = open(filename, 'w+')
+    file = codecs.open(filename, 'w+', encoding='utf-8')
 
     if root == None:
         return

+ 3 - 2
tools/nodeset_compiler/backend_open62541.py

@@ -23,6 +23,7 @@ import string
 from collections import deque
 from os.path import basename
 import logging
+import codecs
 try:
     from StringIO import StringIO
 except ImportError:
@@ -162,7 +163,7 @@ def reorderNodesMinDependencies(nodeset):
 def generateOpen62541Code(nodeset, outfilename, supressGenerationOfAttribute=[], generate_ns0=False, internal_headers=False, typesArray=[], max_string_length=0):
     outfilebase = basename(outfilename)
     # Printing functions
-    outfileh = open(outfilename + ".h", r"w+")
+    outfileh = codecs.open(outfilename + ".h", r"w+", encoding='utf-8')
     outfilec = StringIO()
 
     def writeh(line):
@@ -252,6 +253,6 @@ UA_StatusCode retVal = UA_STATUSCODE_GOOD;
     fullCode = outfilec.getvalue()
     outfilec.close()
 
-    outfilec = open(outfilename + ".c", r"w+")
+    outfilec = codecs.open(outfilename + ".c", r"w+", encoding='utf-8')
     outfilec.write(fullCode)
     outfilec.close()

+ 3 - 2
tools/nodeset_compiler/nodeset.py

@@ -21,7 +21,8 @@ import sys
 import xml.dom.minidom as dom
 from struct import pack as structpack
 from time import struct_time, strftime, strptime, mktime
-import logging;
+import logging
+import codecs
 
 logger = logging.getLogger(__name__)
 
@@ -53,7 +54,7 @@ def extractNamespaces(xmlfile):
     # attempts to do just that.
 
     namespaces = ["http://opcfoundation.org/UA/"]
-    infile = open(xmlfile.name)
+    infile = codecs.open(xmlfile.name, encoding='utf-8')
     foundURIs = False
     nsline = ""
     line = infile.readline()

+ 3 - 2
tools/nodeset_compiler/nodeset_testing.py

@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import codecs
 from nodeset import *
 
 class testing:
@@ -23,7 +24,7 @@ class testing:
         self.ns.allocateVariables()
 
         bin = self.ns.buildBinary()
-        f = open("binary.base64", "w+")
+        f = codecs.open("binary.base64", "w+", encoding='utf-8')
         f.write(bin.encode("base64"))
         f.close()
 
@@ -65,7 +66,7 @@ class testing_open62541_header:
         logger.debug("Phase 3: Calling C Printers")
         code = self.ns.printOpen62541Header()
 
-        codeout = open("./open62541_nodeset.c", "w+")
+        codeout = codecs.open("./open62541_nodeset.c", "w+", encoding='utf-8')
         for line in code:
             codeout.write(line + "\n")
         codeout.close()