From f3c80bc01e5e7f6f882eb5d78f9e8e780211a0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 8 Oct 2019 14:21:26 +0200 Subject: [PATCH] parse_hwdb: bail with an error if no matches or groups are detected pyparsing sometimes changes behaviour and stops giving matches. This should allow us to detect such scenario. With this change, parse_hwdb fails with pyparsing 2.4 on F31. --- hwdb.d/parse_hwdb.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index da0bca5c5d..78c7f9bd56 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -224,11 +224,13 @@ def check_properties(groups): check_one_keycode(prop, parsed.VALUE) def print_summary(fname, groups): + n_matches = sum(len(matches) for matches, props in groups) + n_props = sum(len(props) for matches, props in groups) print('{}: {} match groups, {} matches, {} properties' - .format(fname, - len(groups), - sum(len(matches) for matches, props in groups), - sum(len(props) for matches, props in groups))) + .format(fname, len(groups), n_matches, n_props)) + + if n_matches == 0 or n_props == 0: + error('{}: no matches or props'.format(fname)) if __name__ == '__main__': args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/[67]0-*.hwdb')