Finally I found a solution, which is good enough for me.
On 08/11/2011 12:26 PM, Gelonida N wrote:
See code below:
#!/usr/bin/env python
from pylint import lint
from pylint.reporters.text import TextReporter
from cStringIO import StringIO
filenames = [ __file__ , 'anotherfile.py' ]
for filename in filenames:
#args = [ '-f', 'text', filename ] # BAD
args = [ filename ] # GOOD
my_output = StringIO()
reporter = TextReporter(output=my_output)
lint.Run(args, reporter=reporter, exit=False)
output_str = my_output.getvalue()
print "Got %d characters" % len(output_str)
# do_something_with(output_str)
if I use
args = [ '-f', 'text', filename ]
then the output will not be redirected
if I use on the other hand
args = [ filename ]
then I can capture the output
It seems, the -f option forces the output to the console
This is the only solution, that I found so far, that captures pylint's
output without starting a new process for each file.
the captured output will be identical to the one generated by calling
pylint (without special options) from the command line
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects