I decided to continue the question in another thread as it is actually
another question and as it might easier for other to search.

The new thread is: "How to redirect output of pylint.lint.Run()"


n 08/11/2011 10:33 AM, Gelonida N wrote:
> On 08/11/2011 09:49 AM, Gelonida N wrote:
> 
> 
> My next attempt of redirecting pylint's output is
> to create a text reporter with output set to  a stream object.
> 
> Complete code below.
> 
>> !/usr/bin/env python
>>
>> filenames = [ __file__ ]
>>
>> def do_something_with(strval):
>>     print "Got %d characters" % len(strval)
>>
>> from pylint import lint
>> from pylint.reporters.text import TextReporter
>> from cStringIO import StringIO
>>
>> for filename in filenames:
>>     args = [ '-f',  "text", filename]
>>     my_output = StringIO()
>>     reporter = TextReporter(output=my_output)
>>     #reporter.set_output(my_output)
>>
>>     lint.Run(args, reporter=reporter, exit=False)
>>
>>     output_str = my_output.getvalue()
>>     do_something_with(output_str)
> 
> 
> Output still shows up on the console and output_str has a length of 0
> 
> What am I doing wrong this time.


_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to