From dea8c9f6e83ec9b9d7ba63799f816fd7ecfa6659 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 8 Nov 2015 15:37:58 +0000 Subject: [PATCH] [py3] Compat update process_function_template.py --- scripts/process_function_template.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/process_function_template.py b/scripts/process_function_template.py index 3e9ecc858672..b491405c79e6 100644 --- a/scripts/process_function_template.py +++ b/scripts/process_function_template.py @@ -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" @@ -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): @@ -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) @@ -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()".format(