--- a/incoming.py Sun Jun 19 23:44:42 2016 +0800
+++ b/incoming.py Sun Jun 19 23:51:50 2016 +0800
return domain, user, name
+def match_linter_output(line):
+ m = re.match(r'^(.+):(\d+):\d+: ', line)
+ item['filename'] = m.group(1)
+ 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'
+ item['cls'] = 'warning'
+ return errors, warnings, item
- m = re.match(r'^(.+):(\d+):\d+: ', line)
- item['filename'] = m.group(1)
- item['fileline'] = 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'
- item['cls'] = 'warning'
+ de, dw, extra = match_linter_output(line)
--- a/tests/test_incoming.py Sun Jun 19 23:44:42 2016 +0800
+++ b/tests/test_incoming.py Sun Jun 19 23:51:50 2016 +0800
-from incoming import parse_project_url
+from incoming import match_linter_output, parse_project_url
+def test_match_linter_output():
+ mlo = match_linter_output
+ errors, warnings, extra = mlo('hello.py:42:1: W123 clowntown ahoy')
+ assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
+ assert extra['cls'] == 'warning'
+ assert extra['filename'] == 'hello.py'
+ assert extra['fileline'] == 42
+ errors, warnings, extra = mlo('file with spaces:007:001: [error] oops!')
+ assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
+ assert extra['cls'] == 'error'
+ assert extra['filename'] == 'file with spaces'
+ assert extra['fileline'] == 7
def test_parse_project_url():