def do_text(self, text, args, filename=None): if filename: print 'Checking file:', filename in_file = StringIO(text) out_file = StringIO() pythontidy.tidy_up(file_in=in_file, file_out = out_file) return out_file.getvalue()
def formater(self, pythonshit): #- receive text in string format #- convert it to file-like object inf = StringIO.StringIO() ouf = StringIO.StringIO() inf.write(pythonshit) inf.seek(0) #- pass it through the tidyer pt.tidy_up(inf, ouf) pythonshit = ouf.getvalue() #- return the output as string return pythonshit