Skip to content

Commit dea8c9f

Browse files
committed
[py3] Compat update process_function_template.py
1 parent 313c34c commit dea8c9f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/process_function_template.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import json
44
import glob
55

6+
sys.path.append(
7+
os.path.join(
8+
os.path.dirname(os.path.realpath(__file__)),
9+
'../python/ext-libs'))
10+
11+
from six import string_types
12+
613
cpp = open(sys.argv[1], "w")
714
cpp.write(
815
"#include \"qgsexpression.h\"\n"
@@ -24,7 +31,7 @@ def quote(v):
2431
elif isinstance(v, list):
2532
return map(quote, v)
2633

27-
elif isinstance(v, str) or isinstance(v, unicode):
34+
elif isinstance(v, string_types):
2835
return v.replace('"', '\\"').replace('\n', '\\n')
2936

3037
elif isinstance(v, bool):
@@ -38,7 +45,7 @@ def quote(v):
3845
try:
3946
json_params = json.load(function_file)
4047
except:
41-
print f
48+
print(f)
4249
raise
4350

4451
json_params = quote(json_params)
@@ -66,7 +73,7 @@ def quote(v):
6673
for v in json_params['variants']:
6774
if not 'arguments' in v:
6875
raise BaseException("%s: arguments expected for operator")
69-
if len(v['arguments']) < 1 or len(v['arguments']) > 2:
76+
if len(list(v['arguments'])) < 1 or len(list(v['arguments'])) > 2:
7077
raise BaseException("%s: 1 or 2 arguments expected for operator")
7178

7279
cpp.write("\n\n gFunctionHelpTexts.insert( {0},\n Help( {0}, tr( \"{1}\" ), tr( \"{2}\" ),\n QList<HelpVariant>()".format(

0 commit comments

Comments
 (0)