[PATCH libevdev 2/2] Drop the argparse requirement for make-event-names.py

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 13 20:21:21 PST 2014


We only take one option (linux/input.h) anyway so drop the argparse
requirement. This way libevdev builds on RHEL6 too which doesn't ship
argparse.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/make-event-names.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libevdev/make-event-names.py b/libevdev/make-event-names.py
index 986aaf4..2f6fb78 100755
--- a/libevdev/make-event-names.py
+++ b/libevdev/make-event-names.py
@@ -7,7 +7,6 @@
 from __future__ import print_function
 import re
 import sys
-import argparse
 
 class Bits(object):
 	pass
@@ -226,12 +225,14 @@ def parse(fp):
 
 	return bits
 
+def usage(prog):
+	print("Usage: %s /path/to/linux/input.h" % prog)
+
 if __name__ == "__main__":
-	parser = argparse.ArgumentParser()
-	parser.add_argument('source', metavar="/path/to/linux/input.h",
-			    type=argparse.FileType('r'),
-			    help='source file to parse')
+	if len(sys.argv) != 2:
+		usage(sys.argv[0])
+		sys.exit(2)
 
-	args = parser.parse_args(sys.argv[1:])
-	bits = parse(args.source)
-	print_mapping_table(bits)
+	with open(sys.argv[1]) as f:
+		bits = parse(f)
+		print_mapping_table(bits)
-- 
1.8.4.2



More information about the Input-tools mailing list