[PATCH evemu 01/12] Convert make-event-names.py to allow Python3

Peter Hutterer peter.hutterer at who-t.net
Tue Jul 22 16:42:39 PDT 2014


Python3 doesn't have dict.has_key(), just try to access they key instead and
catch the exception.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/make-event-names.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/make-event-names.py b/src/make-event-names.py
index bc77f2c..2ddfff4 100755
--- a/src/make-event-names.py
+++ b/src/make-event-names.py
@@ -128,9 +128,10 @@ def print_python_mapping_table(bits):
 	print("")
 	print("")
 	print("def event_get_code_name(type, code):")
-	print("	if map.has_key(type) and map[type].has_key(code):")
+	print("	try:")
 	print("		return map[type][code]")
-	print("	return 'UNKNOWN'")
+	print("	except KeyError:")
+	print("		return 'UNKNOWN'")
 	print("")
 
 def parse_define(bits, line):
-- 
1.9.3



More information about the Input-tools mailing list