From 83da6f8fee184bcb96637a88e1b4835746eb80e0 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mar 11 2015 23:17:42 +0000 Subject: report-auto: case-insensitive searching Also use a little nested function to do the normalization as it looks really ugly retyped a dozen times. --- diff --git a/relval/cli.py b/relval/cli.py index 681dc49..26e941f 100755 --- a/relval/cli.py +++ b/relval/cli.py @@ -878,16 +878,22 @@ On behalf of: {7} sys.exit("Specified compose does not exist, or specified test " "type does not exist for specified compose.") + def _normalize(text): + """Lower case and replace ' ' with '_' so I don't have to + keep retyping it. + """ + return text.lower().replace(' ', '_') + # Find the right row - rows = [r for r in rows if args.testcase.replace(' ', '_') in - r.testcase.replace(' ', '_') or args.testcase.replace(' ', '_') - in r.name.replace(' ', '_')] + rows = [r for r in rows if + _normalize(args.testcase) in _normalize(r.testcase) or + _normalize(args.testcase) in _normalize(r.name)] if len(rows) > 1: - rows = [r for r in rows if args.section.replace(' ', '_') in - r.section.replace(' ', '_')] + rows = [r for r in rows if _normalize(args.section) in + _normalize(r.section)] if len(rows) > 1: - rows = [r for r in rows if args.testname.replace(' ', '_') in - r.name.replace(' ', '_')] + rows = [r for r in rows if _normalize(args.testname) in + _normalize(r.name)] if not rows: sys.exit("Specified test case cannot be found.") if len(rows) > 1: