History

Python 3: coerce iterators into lists where necessary

Nils Philippsen committed 10 years ago

Commit 8b8a0201 parent a49a3f02 files · +10 −4Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/lib/gen_pyobject.py +1 −1
  2. python/lib/generator.py +9 −3
python/lib/gen_pyobject.py+1−1
@@ -70,7 +70,7 @@ def get_params_types_names(proto): · 69 unmodified lines
70 example: proto = "int main (int argc, char ** argv)"70 example: proto = "int main (int argc, char ** argv)"
71 returns: [['int', 'argc'], ['char **','argv']]71 returns: [['int', 'argc'], ['char **','argv']]
72 """72 """
73 return map(split_type, get_params(proto)) 73 return list(map(split_type, get_params(proto)))
74 74
75def get_return_type(proto):75def get_return_type(proto):
76 import re76 import re
python/lib/generator.py+9−3
@@ -11,6 +11,7 @@ def get_cpp_objects(): · 10 unmodified lines
11 11
12 cpp_output = filter(lambda y: len(y) > 1, cpp_output)12 cpp_output = filter(lambda y: len(y) > 1, cpp_output)
13 cpp_output = filter(lambda y: not y.startswith('#'), cpp_output)13 cpp_output = filter(lambda y: not y.startswith('#'), cpp_output)
14 cpp_output = list(cpp_output)
14 15
15 i = 116 i = 1
16 while 1:17 while 1:
@@ -85,9 +86,11 @@ def generate_object_files(output_path): · 68 unmodified lines
85 object_methods = filter(lambda x: this_object in x, cpp_output)86 object_methods = filter(lambda x: this_object in x, cpp_output)
86 object_methods = [a.strip() for a in object_methods]87 object_methods = [a.strip() for a in object_methods]
87 object_methods = filter(lambda x: not x.startswith('typedef'), object_methods)88 object_methods = filter(lambda x: not x.startswith('typedef'), object_methods)
89 object_methods = list(object_methods)
88 #for method in object_methods:90 #for method in object_methods:
89 # write_msg(method)91 # write_msg(method)
90 new_methods = filter(lambda x: 'new_'+object_name in x, object_methods)92 new_methods = list(filter(
93 lambda x: 'new_'+object_name in x, object_methods))
91 if len(new_methods) > 1:94 if len(new_methods) > 1:
92 write_msg("-- WARNING: more than one new method for", object_name)95 write_msg("-- WARNING: more than one new method for", object_name)
93 for method in new_methods:96 for method in new_methods:
@@ -98,7 +101,8 @@ def generate_object_files(output_path): · 4 unmodified lines
98 for method in new_methods:101 for method in new_methods:
99 write_msg(method)102 write_msg(method)
100 103
101 del_methods = filter(lambda x: 'del_'+object_name in x, object_methods)104 del_methods = list(filter(
105 lambda x: 'del_'+object_name in x, object_methods))
102 if len(del_methods) > 1:106 if len(del_methods) > 1:
103 write_msg("-- WARNING: more than one del method for", object_name)107 write_msg("-- WARNING: more than one del method for", object_name)
104 for method in del_methods:108 for method in del_methods:
@@ -106,7 +110,8 @@ def generate_object_files(output_path): · 1 unmodified line
106 elif len(del_methods) < 1:110 elif len(del_methods) < 1:
107 write_msg("-- WARNING: no del method for", object_name)111 write_msg("-- WARNING: no del method for", object_name)
108 112
109 do_methods = filter(lambda x: object_name+'_do' in x, object_methods)113 do_methods = list(filter(
114 lambda x: object_name+'_do' in x, object_methods))
110 if len(do_methods) > 1:115 if len(do_methods) > 1:
111 pass116 pass
112 #write_msg("-- WARNING: more than one do method for", object_name)117 #write_msg("-- WARNING: more than one do method for", object_name)
@@ -135,6 +140,7 @@ def generate_object_files(output_path): · 22 unmodified lines
135 other_methods = filter(lambda x: x not in do_methods, other_methods)140 other_methods = filter(lambda x: x not in do_methods, other_methods)
136 other_methods = filter(lambda x: x not in get_methods, other_methods)141 other_methods = filter(lambda x: x not in get_methods, other_methods)
137 other_methods = filter(lambda x: x not in set_methods, other_methods)142 other_methods = filter(lambda x: x not in set_methods, other_methods)
143 other_methods = list(other_methods)
138 144
139 if len(other_methods) > 0:145 if len(other_methods) > 0:
140 write_msg("-- WARNING: some methods for", object_name, "were unidentified")146 write_msg("-- WARNING: some methods for", object_name, "were unidentified")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t