diff options
-rw-r--r-- | Tools/px4params/output_dokuwiki_listings.py | 3 | ||||
-rw-r--r-- | Tools/px4params/output_dokuwiki_tables.py | 5 | ||||
-rw-r--r-- | Tools/px4params/output_xml.py | 7 | ||||
-rw-r--r-- | Tools/px4params/scanner.py | 3 |
4 files changed, 11 insertions, 7 deletions
diff --git a/Tools/px4params/output_dokuwiki_listings.py b/Tools/px4params/output_dokuwiki_listings.py index 117f4edf4..83c50ae15 100644 --- a/Tools/px4params/output_dokuwiki_listings.py +++ b/Tools/px4params/output_dokuwiki_listings.py @@ -1,3 +1,4 @@ +import codecs class DokuWikiListingsOutput(): def __init__(self, groups): @@ -26,5 +27,5 @@ class DokuWikiListingsOutput(): self.output = result def Save(self, filename): - with open(filename, 'w') as f: + with codecs.open(filename, 'w', 'utf-8') as f: f.write(self.output) diff --git a/Tools/px4params/output_dokuwiki_tables.py b/Tools/px4params/output_dokuwiki_tables.py index dca3fd92d..aa04304df 100644 --- a/Tools/px4params/output_dokuwiki_tables.py +++ b/Tools/px4params/output_dokuwiki_tables.py @@ -1,4 +1,5 @@ from xml.sax.saxutils import escape +import codecs class DokuWikiTablesOutput(): def __init__(self, groups): @@ -44,11 +45,11 @@ class DokuWikiTablesOutput(): self.output = result; def Save(self, filename): - with open(filename, 'w') as f: + with codecs.open(filename, 'w', 'utf-8') as f: f.write(self.output) def SaveRpc(self, filename): - with open(filename, 'w') as f: + with codecs.open(filename, 'w', 'utf-8') as f: f.write("""<?xml version='1.0'?> <methodCall> <methodName>wiki.putPage</methodName> diff --git a/Tools/px4params/output_xml.py b/Tools/px4params/output_xml.py index 5576954c0..e845cd1b1 100644 --- a/Tools/px4params/output_xml.py +++ b/Tools/px4params/output_xml.py @@ -1,4 +1,5 @@ from xml.dom.minidom import getDOMImplementation +import codecs class XMLOutput(): def __init__(self, groups): @@ -18,8 +19,8 @@ class XMLOutput(): xml_param.appendChild(xml_field) xml_value = xml_document.createTextNode(value) xml_field.appendChild(xml_value) - self.output = xml_document.toprettyxml(indent=" ", newl="\n", encoding="utf-8") + self.xml_document = xml_document def Save(self, filename): - with open(filename, 'wb') as f: - f.write(self.output) + with codecs.open(filename, 'w', 'utf-8') as f: + self.xml_document.writexml(f, indent=" ", addindent=" ", newl="\n") diff --git a/Tools/px4params/scanner.py b/Tools/px4params/scanner.py index b5a1af47c..8779b7bbf 100644 --- a/Tools/px4params/scanner.py +++ b/Tools/px4params/scanner.py @@ -1,5 +1,6 @@ import os import re +import codecs class Scanner(object): """ @@ -29,6 +30,6 @@ class Scanner(object): Scans provided file and passes its contents to the parser using parser.Parse method. """ - with open(path, 'r') as f: + with codecs.open(path, 'r', 'utf-8') as f: contents = f.read() parser.Parse(contents) |