From: Nils Philippsen Date: Wed, 25 Nov 2015 23:09:08 +0000 (+0100) Subject: Python 3: coerce iterators into lists where necessary X-Git-Tag: 0.4.4~300^2~320^2~3 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=8b8a0203cfe66c34655acc40fa147e6e8e3fe09b;p=aubio.git Python 3: coerce iterators into lists where necessary --- diff --git a/python/lib/gen_pyobject.py b/python/lib/gen_pyobject.py index ba8274e5..1cc9bde5 100644 --- a/python/lib/gen_pyobject.py +++ b/python/lib/gen_pyobject.py @@ -70,7 +70,7 @@ def get_params_types_names(proto): example: proto = "int main (int argc, char ** argv)" returns: [['int', 'argc'], ['char **','argv']] """ - return map(split_type, get_params(proto)) + return list(map(split_type, get_params(proto))) def get_return_type(proto): import re diff --git a/python/lib/generator.py b/python/lib/generator.py index 7d959459..90c145d6 100755 --- a/python/lib/generator.py +++ b/python/lib/generator.py @@ -11,6 +11,7 @@ def get_cpp_objects(): cpp_output = filter(lambda y: len(y) > 1, cpp_output) cpp_output = filter(lambda y: not y.startswith('#'), cpp_output) + cpp_output = list(cpp_output) i = 1 while 1: @@ -85,9 +86,11 @@ def generate_object_files(output_path): object_methods = filter(lambda x: this_object in x, cpp_output) object_methods = [a.strip() for a in object_methods] object_methods = filter(lambda x: not x.startswith('typedef'), object_methods) + object_methods = list(object_methods) #for method in object_methods: # write_msg(method) - new_methods = filter(lambda x: 'new_'+object_name in x, object_methods) + new_methods = list(filter( + lambda x: 'new_'+object_name in x, object_methods)) if len(new_methods) > 1: write_msg("-- WARNING: more than one new method for", object_name) for method in new_methods: @@ -98,7 +101,8 @@ def generate_object_files(output_path): for method in new_methods: write_msg(method) - del_methods = filter(lambda x: 'del_'+object_name in x, object_methods) + del_methods = list(filter( + lambda x: 'del_'+object_name in x, object_methods)) if len(del_methods) > 1: write_msg("-- WARNING: more than one del method for", object_name) for method in del_methods: @@ -106,7 +110,8 @@ def generate_object_files(output_path): elif len(del_methods) < 1: write_msg("-- WARNING: no del method for", object_name) - do_methods = filter(lambda x: object_name+'_do' in x, object_methods) + do_methods = list(filter( + lambda x: object_name+'_do' in x, object_methods)) if len(do_methods) > 1: pass #write_msg("-- WARNING: more than one do method for", object_name) @@ -135,6 +140,7 @@ def generate_object_files(output_path): other_methods = filter(lambda x: x not in do_methods, other_methods) other_methods = filter(lambda x: x not in get_methods, other_methods) other_methods = filter(lambda x: x not in set_methods, other_methods) + other_methods = list(other_methods) if len(other_methods) > 0: write_msg("-- WARNING: some methods for", object_name, "were unidentified")