2014-03-07 4 views
1

저는 Python 3.3, Windows, pip tool을 통해 pylint를 설치했습니다.
나는이 내 파일을 확인하고 지금과 같은 출력을Pylint : 스크립트를 통해 출력물을 얻습니다. pylint 실행 파일과 유사합니다.

************* Module sample_plugin 
1:0:C0111: Missing module docstring 
1:0:F0401: Unable to import 'tst' 
3:0:W0232: Class has no __init__ method 
3:0:C0111: Missing class docstring 
3:0:C1001: Old-style class defined. 
4:4:C0111: Missing method docstring 

을 제공

pylint --msg-template="{line}:{column}:{msg_id}: {msg}" --module-rgx=.* --reports=n --persistent=n "D:\TestLint\sample_plugin.py" 

도구 (매개 변수 중요한, 내가 특별한 일반 텍스트 출력을 필요로) "pylint.exe \ 스크립트"를 통해 이러한 명령을 실행할 수 있습니다 Python 코드를 통해 pylint를 사용하고 EXE 도구를 사용하지 않습니다. 그리고 내 테스트 파일 에 대해 비슷하거나 동일한 출력을 원합니다. 그래서 질문. pylint를 호출하고 동일한 출력 (문자열 또는 목록)을 얻기 위해 작성할 수있는 Py 스크립트는 무엇입니까?

답변

0

이렇게하는 방법은 여러 가지가 있습니다. 가장 간단한 것 : 당신이 하위 프로세스에 pylint를 실행하려면

from pylint.lint import Run 
Run([file_or_module, '--message-template', '...']) 

(다중 실행 권장)이 시도 :

from pylint.epylint import lint 
lint(file_or_module, [--message-template', '...']