Cleaner error handling for pylint.

This commit is contained in:
LCD 47 2013-09-20 07:49:19 +03:00
parent 0048156d8f
commit 3eb51f1e26

View File

@ -7,18 +7,19 @@
if exists("g:loaded_syntastic_python_pylint_checker") if exists("g:loaded_syntastic_python_pylint_checker")
finish finish
endif endif
let g:loaded_syntastic_python_pylint_checker=1 let g:loaded_syntastic_python_pylint_checker = 1
let s:pylint_new = -1
function! SyntaxCheckers_python_pylint_IsAvailable() function! SyntaxCheckers_python_pylint_IsAvailable()
return executable('pylint') let s:pylint_new = executable('pylint') ? s:PylintNew() : -1
return s:pylint_new >= 0
endfunction endfunction
function! SyntaxCheckers_python_pylint_GetLocList() function! SyntaxCheckers_python_pylint_GetLocList()
let pylint_new = s:PylintNew()
let makeprg = syntastic#makeprg#build({ let makeprg = syntastic#makeprg#build({
\ 'exe': 'pylint', \ 'exe': 'pylint',
\ 'args': (pylint_new ? '--msg-template="{path}:{line}: [{msg_id}] {msg}" -r n' : '-f parseable -r n -i y'), \ 'args': (s:pylint_new ? '--msg-template="{path}:{line}: [{msg_id}] {msg}" -r n' : '-f parseable -r n -i y'),
\ 'filetype': 'python', \ 'filetype': 'python',
\ 'subchecker': 'pylint' }) \ 'subchecker': 'pylint' })
@ -51,10 +52,12 @@ endfunction
function s:PylintNew() function s:PylintNew()
try try
let pylint_version = filter(split(system('pylint --version'), '\m, \|\n'), 'v:val =~# "^pylint"')[0] let pylint_version = filter(split(system('pylint --version'), '\m, \|\n'), 'v:val =~# "^pylint"')[0]
return syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1]) let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
catch /E684/ catch /E684/
return 0 call syntastic#util#error("checker python/pylint: can't parse version string (abnormal termination?)")
let ret = -1
endtry endtry
return ret
endfunction endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({