def check_style(self, ev=None): """ Runs pep8 stylecheck, captures output and prints to new output window.""" sbind = ScriptBinding(self.editwin) filename = sbind.getfilename() if filename: try: p = sub.Popen(['pep8', filename], stdout=sub.PIPE, stderr=sub.PIPE) output, errors = p.communicate() if output.strip(): output_short = '\n'.join( [line.split('/')[-1] for line in output.split('\n')[:-1]]) # shorten pathname in each line of output else: output_short = "Passed all checks!" except OSError: output_short = "Please install pep8." win = OutputWindow(self.editwin.flist) win.write(output_short)
def doc_test(self, ev=None): """ Run doctests on the current module""" sbind = ScriptBinding(self.editwin) filename = sbind.getfilename() if filename: p = sub.Popen(['python', '-m', 'doctest', '-v', filename], stdout=sub.PIPE, stderr=sub.PIPE) output, errors = p.communicate() win = OutputWindow(self.editwin.flist) win.write(output + '\n' + errors) # write to output window