[PATCH evemu 13/19] py: Generate complete dicts in event_names.py

Daniel Martin consume.noise at gmail.com
Mon Jan 6 09:38:13 PST 2014


Before, the generated dictionaries in event_names.py just had the bits
to name mapping and a loop to add the name to bits mapping using items()
afterwards. As of Python 3 items() returns a view, not a copy, resulting
in an error as the dictionary was modified in place.

Now, generate both the bits to name and name to bits mapping when
creating event_names.py and make the loop obsolete.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 src/make-event-names.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/make-event-names.py b/src/make-event-names.py
index a62c2c3..296ae0e 100755
--- a/src/make-event-names.py
+++ b/src/make-event-names.py
@@ -58,10 +58,8 @@ def print_python_bits(bits, prefix):
 
 	print("%s_map = {" % (prefix))
 	for val, name in getattr(bits, prefix).items():
-		print("	%d : \"%s\"," % (val, name))
+		print("	%d : \"%s\", \"%s\" : %d," % (val, name, name, val))
 	print("}")
-	print("for k, v in %s_map.items():" % (prefix))
-	print("	%s_map[v] = k" % (prefix))
 	print("")
 
 def print_map(bits):
-- 
1.8.5.2



More information about the Input-tools mailing list