On 08/03/2010 09:33 AM, Sylvain Thénault wrote:
Hi Sylvain,
>> occasionally we'd like to run pylint on quite many files.
>>
>> If doing this the naive way
>> (running a python scipt with os.walk calling then python with pylint)
>> under windows, then quite some time is spent on starting and stopping
>> new executables.
>>
>> Is there a simple way of running pylint on many files without having to
>> start python for each check.
>>
>> Additionally I would only be interested in the amount of errors, the
>> amount of warnings and coding style violations and the overal score.
>
> You can easily run pylint programmatically. See pylint.lint.Run class
> (its __init__ method actually). You can then easily give a custom
> reporter that only display what you're interested in.
Finally (almost a year later :-( )
I wanted to try using pylint.lint.Run() from within a script in order to
avoid respawning a new python process for each lint run
my current script looks like:
for filename in filenames:
cmd = [ 'pylint', '-f', "text", pm_file)
linter = Popen(cmd, stdout=PIPE, stderr=PIPE)
output = linter.communicate()
exit_code = linter.returncode
do_something_with(output, exitcode)
Now I try to change it to use pylint.lint.Run()
y first test was just performing multiple runs without even trying to
capture the outpout
from pylint import lint
for filename in filenames:
args = [ '-f', "text", pm_file)
lint.Run(args) # first attempt without capturing output
However it seems, that Run exits immediately after the first linting
process.
I found some documentation on the web
http://www.logilab.org/card/pylint_manual
The footline mentions:
card #5560 - latest update on 2011/08/08, . . .
This documentation mentions to use:
mentioning following text:
> It is also possible to call Pylint from an other Python program,
> thanks to py_run() function in lint module,
> assuming Pylint options are stored in pylint_options string, as
>
>
> from pylint import lint
> lint.py_run( pylint_options)
>
>
> To silently run Pylint on a module_name.py module,
> and get its standart output and error:
>
>
> from pylint import lint
> (pylint_stdout, pylint_stderr) = lint.py_run( 'module_name.py', True)
However I can't find py_run in lint
What is the correct way to parse multiple python files from the same
executable.
Version info:
pylint 0.24.0,
astng 0.22.0, common 0.56.1
Python 2.6.5 (r265:79063, A
[GCC 4.4.3]
Thanks in advance for any further info.
Ideally I would get the same output as if I were calling pylint from the
command line, because in this case I would not have to cahnge my custom
function do_something_with(output, exitcode)
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects