[dak/master 11/23] Use named groups in lintian regex.
Signed-off-by: Chris Lamb <lamby@debian.org>
---
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 6be9997..9040e21 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"^(?P<level>W|E|O): (?P<package>.*?): (?P<tag>[^ ]*) ?(?P<description>.*)$")
diff --git a/tests/test_regexes.py b/tests/test_regexes.py
index 8faf9a0..bde1727 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__':
--
1.6.3.3
Reply to: