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

Benjamin Tissoires benjamin.tissoires at gmail.com
Tue Jan 14 11:52:32 PST 2014


On Mon, Jan 13, 2014 at 11:21 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> 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)

Well, I prefer the code with argparse, but I understand the need to
remove the dependency.

If you also remove the argparse dependency in configure.ac, you have
my Reviewed-by!

Cheers,
Benjamin


More information about the Input-tools mailing list