From d860b7001ae7735b7876fea0680fc6dc407caff4 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sat, 31 Oct 2009 10:41:42 +0000 Subject: [PATCH] Use named groups in lintian regex. Signed-off-by: Chris Lamb --- daklib/regexes.py | 2 +- tests/test_regexes.py | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/daklib/regexes.py b/daklib/regexes.py index 6be99977..9040e217 100755 --- a/daklib/regexes.py +++ b/daklib/regexes.py @@ -112,4 +112,4 @@ re_user_mails = re.compile(r"^(pub|uid):[^rdin].*<(.*@.*)>.*$", re.MULTILINE); re_user_name = re.compile(r"^pub:.*:(.*)<.*$", re.MULTILINE); re_re_mark = re.compile(r'^RE:') -re_parse_lintian = re.compile(r"^(W|E|O): (.*?): ([^ ]*) ?(.*)$") +re_parse_lintian = re.compile(r"^(?PW|E|O): (?P.*?): (?P[^ ]*) ?(?P.*)$") diff --git a/tests/test_regexes.py b/tests/test_regexes.py index 8faf9a0a..bde17275 100755 --- a/tests/test_regexes.py +++ b/tests/test_regexes.py @@ -34,26 +34,46 @@ class re_parse_lintian(DakTestCase): def testBinary(self): self.assertEqual( - self.MATCH('W: pkgname: some-tag path/to/file').groups(), - ('W', 'pkgname', 'some-tag', 'path/to/file') + self.MATCH('W: pkgname: some-tag path/to/file').groupdict(), + { + 'level': 'W', + 'package': 'pkgname', + 'tag': 'some-tag', + 'description': 'path/to/file', + } ) def testBinaryNoDescription(self): self.assertEqual( - self.MATCH('W: pkgname: some-tag').groups(), - ('W', 'pkgname', 'some-tag', '') + self.MATCH('W: pkgname: some-tag').groupdict(), + { + 'level': 'W', + 'package': 'pkgname', + 'tag': 'some-tag', + 'description': '', + } ) def testSource(self): self.assertEqual( - self.MATCH('W: pkgname source: some-tag').groups(), - ('W', 'pkgname source', 'some-tag', '') + self.MATCH('W: pkgname source: some-tag').groupdict(), + { + 'level': 'W', + 'package': 'pkgname source', + 'tag': 'some-tag', + 'description': '', + } ) def testSourceNoDescription(self): self.assertEqual( - self.MATCH('W: pkgname source: some-tag path/to/file').groups(), - ('W', 'pkgname source', 'some-tag', 'path/to/file') + self.MATCH('W: pkgname source: some-tag path/to/file').groupdict(), + { + 'level': 'W', + 'package': 'pkgname source', + 'tag': 'some-tag', + 'description': 'path/to/file', + } ) if __name__ == '__main__': -- 2.39.5