Download:
child 109:6cbbab799f3c
parent 107:699663b276ac
108:4fced0617745
Anton Shestakov <av6@dwimlabs.net>, Tue, 05 Jul 2016 20:44:04 +0800
incoming: extract link start/end from linter output

2 файлов изменено, 27 вставок(+), 7 удалений(-) [+]
incoming.py file | annotate | diff | comparison | revisions
tests/test_incoming.py file | annotate | diff | comparison | revisions
--- a/incoming.py Tue Jul 05 20:42:35 2016 +0800
+++ b/incoming.py Tue Jul 05 20:44:04 2016 +0800
@@ -40,10 +40,12 @@
warnings = 0
item = {}
- m = re.match(r'^(?P<filename>.+):(?P<fileline>\d+):\d+: ', line)
+ m = re.match(r'^(?P<filename>.+):(?P<line_number>\d+):\d+: ', line)
if m is not None:
item['filename'] = m.group('filename')
- item['fileline'] = int(m.group('fileline'))
+ item['line_number'] = int(m.group('line_number'))
+ item['link_start'] = m.start('filename')
+ item['link_end'] = m.end('line_number')
rest = line[m.end():]
patterns = (
--- a/tests/test_incoming.py Tue Jul 05 20:42:35 2016 +0800
+++ b/tests/test_incoming.py Tue Jul 05 20:44:04 2016 +0800
@@ -3,7 +3,7 @@
def test_match_linter_output():
mlo = match_linter_output
- usual_keys = ['cls', 'fileline', 'filename']
+ usual_keys = ['cls', 'filename', 'line_number', 'link_end', 'link_start']
errors, warnings, extra = mlo('hello.py:42:1: W123 clowntown ahoy')
assert errors == 0
@@ -11,7 +11,9 @@
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'warning'
assert extra['filename'] == 'hello.py'
- assert extra['fileline'] == 42
+ assert extra['line_number'] == 42
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 11
errors, warnings, extra = mlo('file with spaces:007:001: [error] oops!')
assert errors == 1
@@ -19,7 +21,9 @@
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'error'
assert extra['filename'] == 'file with spaces'
- assert extra['fileline'] == 7
+ assert extra['line_number'] == 7
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 20
errors, warnings, extra = mlo('requirements.txt:1:1: PIL is obsolete.')
assert errors == 0
@@ -27,7 +31,9 @@
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'warning'
assert extra['filename'] == 'requirements.txt'
- assert extra['fileline'] == 1
+ assert extra['line_number'] == 1
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 18
errors, warnings, extra = mlo('ham.lua:414:90: (E101) foo is not good')
assert errors == 1
@@ -35,7 +41,19 @@
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'error'
assert extra['filename'] == 'ham.lua'
- assert extra['fileline'] == 414
+ assert extra['line_number'] == 414
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 11
+
+ errors, warnings, extra = mlo('backwards.js:9091:1: not perfect (W201)')
+ assert errors == 0
+ assert warnings == 1
+ assert sorted(extra.keys()) == usual_keys
+ assert extra['cls'] == 'warning'
+ assert extra['filename'] == 'backwards.js'
+ assert extra['line_number'] == 9091
+ assert extra['link_start'] == 0
+ assert extra['link_end'] == 17
def test_parse_project_url():