On 11/08/2011, at 10:16 , Gelonida N wrote:
> 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.
Always a good idea to either check the source when you have it ... or at the
very least use pydoc ...
$ pydoc pylint.lint.Run
Help on class Run in pylint.lint:
pylint.lint.Run = class Run
| helper class to use as main for pylint :
|
| run(*sys.argv[1:])
|
| Methods defined here:
|
| __init__(self, args, reporter=None, exit=True)
So lint.Run takes an "exit" keyword. Try setting that to False in your script
above
lint.Run(Args, exit=False)
d.
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects