--- a/incoming.py Sun Jun 19 23:51:50 2016 +0800
+++ b/incoming.py Mon Jun 20 00:11:57 2016 +0800
item['fileline'] = int(m.group(2))
- # https://pep8.readthedocs.io/en/latest/intro.html#error-codes
- if re.match(r'^E9\d{2}', rest) is not None:
- elif re.match(r'^[EWFCN]\d{3}', rest) is not None:
- item['cls'] = 'warning'
- elif re.match(r'^\[error\]', rest) is not None:
- elif re.match(r'^\[warning\]', rest) is not None:
- item['cls'] = 'warning'
- elif re.match(r'^\(E\d{3}\)', rest) is not None:
- elif re.match(r'^\(W\d{3}\)', rest) is not None:
- item['cls'] = 'warning'
+ # https://pep8.readthedocs.io/en/latest/intro.html#error-codes
+ (r'^E9\d{2}', 'error'),
+ (r'^[EWFCN]\d{3}', 'warning'),
+ (r'^\[error\]', 'error'),
+ (r'^\[warning\]', 'warning'),
+ (r'^\(E\d{3}\)', 'error'),
+ (r'^\(W\d{3}\)', 'warning'),
+ for regex, cls in patterns:
+ m = re.match(regex, rest)
--- a/tests/test_incoming.py Sun Jun 19 23:51:50 2016 +0800
+++ b/tests/test_incoming.py Mon Jun 20 00:11:57 2016 +0800
assert extra['filename'] == 'file with spaces'
assert extra['fileline'] == 7
+ errors, warnings, extra = mlo('requirements.txt:1:1: PIL is obsolete.')
+ assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
+ assert extra['cls'] == 'warning'
+ assert extra['filename'] == 'requirements.txt'
+ assert extra['fileline'] == 1
def test_parse_project_url():
result = parse_project_url('https://example.com/alice/hello-world')