wmlindent: open files as UTF-8 and use Unicode literals

This commit is contained in:
Elvish_Hunter 2015-08-02 21:58:33 +02:00
parent 66511d2c2a
commit 501b3aa2d9

View file

@ -61,9 +61,9 @@ if there's an indent open at end of file or if a closer occurs with
indent already zero; these two conditions strongly suggest unbalanced WML.
"""
from __future__ import print_function
from __future__ import print_function, unicode_literals
import sys, os, getopt, filecmp, re
import sys, os, getopt, filecmp, re, codecs
from wesnoth import wmltools
closer_prefixes = ["{NEXT "]
@ -245,7 +245,7 @@ def convertor(linefilter, arglist, exclude):
continue
else:
try:
with open(filename,"rb") as infp, open(filename + ".out", "wb") as outfp:
with codecs.open(filename,"r","utf8") as infp, codecs.open(filename + ".out", "w","utf8") as outfp:
linefilter(filename, infp, outfp)
except bailout as e:
print('wmlindent: "%s", %d: %s' % (e.filename, e.lineno, e.msg), file=sys.stderr)