Skip to content
Permalink
Browse files

handle utf-8 in function help

  • Loading branch information
jef-n committed Sep 17, 2018
1 parent 239e93d commit d37a79943f21e8ead946c76b55f9a56c784c4b2f
Showing with 6 additions and 6 deletions.
  1. +6 −6 scripts/process_function_template.py
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import sys
import os
import json
@@ -8,9 +10,7 @@
os.path.dirname(os.path.realpath(__file__)),
'../python/ext-libs'))

from six import string_types

cpp = open(sys.argv[1], "w")
cpp = open(sys.argv[1], "w", encoding="utf-8")
cpp.write(
"#include \"qgsexpression.h\"\n"
"\n"
@@ -31,7 +31,7 @@ def quote(v):
elif isinstance(v, list):
return map(quote, v)

elif isinstance(v, string_types):
elif isinstance(v, str):
return v.replace('"', '\\"').replace('\n', '\\n')

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


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

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

0 comments on commit d37a799

Please sign in to comment.
You can’t perform that action at this time.