Skip to content

Commit d37a799

Browse files
committedSep 17, 2018
handle utf-8 in function help
1 parent 239e93d commit d37a799

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎scripts/process_function_template.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
13
import sys
24
import os
35
import json
@@ -8,9 +10,7 @@
810
os.path.dirname(os.path.realpath(__file__)),
911
'../python/ext-libs'))
1012

11-
from six import string_types
12-
13-
cpp = open(sys.argv[1], "w")
13+
cpp = open(sys.argv[1], "w", encoding="utf-8")
1414
cpp.write(
1515
"#include \"qgsexpression.h\"\n"
1616
"\n"
@@ -31,7 +31,7 @@ def quote(v):
3131
elif isinstance(v, list):
3232
return map(quote, v)
3333

34-
elif isinstance(v, string_types):
34+
elif isinstance(v, str):
3535
return v.replace('"', '\\"').replace('\n', '\\n')
3636

3737
elif isinstance(v, bool):
@@ -42,7 +42,7 @@ def quote(v):
4242

4343

4444
for f in sorted(glob.glob('resources/function_help/json/*')):
45-
with open(f) as function_file:
45+
with open(f, encoding="utf-8") as function_file:
4646
try:
4747
json_params = json.load(function_file)
4848
except:
@@ -103,7 +103,7 @@ def quote(v):
103103

104104
if 'examples' in v:
105105
for e in v['examples']:
106-
cpp.write("\n << HelpExample( tr( \"{0}\" ), tr( \"{1}\" ), tr( \"{2}\") )".format(
106+
cpp.write("\n << HelpExample( tr( \"{0}\" ), tr( \"{1}\" ), tr( \"{2}\" ) )".format(
107107
e['expression'],
108108
e['returns'],
109109
e.get('note', ''))

0 commit comments

Comments
 (0)
Please sign in to comment.