diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-10-30 11:15:49 +1000 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2019-11-01 10:24:03 +0200 |
commit | 1e13190685ff7c2da2cb4af367191dddd92df17f (patch) | |
tree | b75ef8632458d9f686a62b6fa8fdc53904b423b0 /test/xkeyboard-config-test.py.in | |
parent | 90497b84f88656ec151076644c5c69c3507ca3a9 (diff) | |
download | xorg-lib-libxkbcommon-1e13190685ff7c2da2cb4af367191dddd92df17f.tar.gz |
test: xkeyboard-config: use argparse for the path and the tool selection
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/xkeyboard-config-test.py.in')
-rwxr-xr-x | test/xkeyboard-config-test.py.in | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/test/xkeyboard-config-test.py.in b/test/xkeyboard-config-test.py.in index 345ebd5..9516b2c 100755 --- a/test/xkeyboard-config-test.py.in +++ b/test/xkeyboard-config-test.py.in @@ -1,4 +1,5 @@ #!/usr/bin/env python +import argparse import sys import subprocess import os @@ -89,7 +90,7 @@ def xkbcomp(r='evdev', m='pc105', l='us', v='', o=''): print(err.output.decode('utf-8')) -def parse(root): +def parse(root, tool): layouts = root.findall('layoutList/layout') options = [ @@ -97,10 +98,6 @@ def parse(root): for e in root.findall('optionList/group/option/configItem/name') ] - # Switch this to xkbcomp if needed. - tool = xkbcommontool - # tool = xkbcomp - for l in progress_bar(layouts, 'layout '): layout = l.find('configItem/name').text tool(l=layout) @@ -115,14 +112,28 @@ def parse(root): def main(args): - try: - path = args[1] - except IndexError: - path = DEFAULT_RULES_XML - - with open(path) as f: + tools = { + 'libxkbcommon': xkbcommontool, + 'xkbcomp': xkbcomp, + } + + parser = argparse.ArgumentParser( + description='Tool to test all layout/variant/option combinations.' + ) + parser.add_argument('path', metavar='/path/to/evdev.xml', + nargs='?', type=str, + default=DEFAULT_RULES_XML, + help='Path to xkeyboard-config\'s evdev.xml') + parser.add_argument('--tool', choices=tools.keys(), + type=str, default='libxkbcommon', + help='parsing tool to use') + args = parser.parse_args() + + tool = tools[args.tool] + + with open(args.path) as f: root = ET.fromstring(f.read()) - parse(root) + parse(root, tool) if __name__ == '__main__': |