Skip to content

Commit

Permalink
[py3] Compat update process_function_template.py
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 16, 2015
1 parent 313c34c commit dea8c9f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scripts/process_function_template.py
Expand Up @@ -3,6 +3,13 @@
import json
import glob

sys.path.append(
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'../python/ext-libs'))

from six import string_types

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

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

elif isinstance(v, bool):
Expand All @@ -38,7 +45,7 @@ def quote(v):
try:
json_params = json.load(function_file)
except:
print f
print(f)
raise

json_params = quote(json_params)
Expand Down Expand Up @@ -66,7 +73,7 @@ def quote(v):
for v in json_params['variants']:
if not 'arguments' in v:
raise BaseException("%s: arguments expected for operator")
if len(v['arguments']) < 1 or len(v['arguments']) > 2:
if len(list(v['arguments'])) < 1 or len(list(v['arguments'])) > 2:
raise BaseException("%s: 1 or 2 arguments expected for operator")

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

0 comments on commit dea8c9f

Please sign in to comment.