#!/usr/bin/python import sys import codecs HTML_START = """ Dosage comic status """ HTML_END = """ """ def main(args=None): if args is None: args = sys.argv[1:] filename = 'testresults.txt' with open(filename) as fp: tests = parse_test_data(fp) output = 'table.html' with codecs.open(output, 'w', 'utf-8') as fp: render_test_data(tests, fp) def get_comic_name(line): return line.split('::')[1][4:] def parse_test_data(fp): data = [] for line in fp: if line.rstrip().endswith('::test_comic'): name = get_comic_name(line) failed = line.startswith('F') data.append((name, failed)) data.sort() return data def render_test_data(tests, fp): fp.write(HTML_START) fp.write('\n') for name, failed in tests: status = failed and "broken" or "ok" fp.write('\n' % (name, status)) fp.write('
NameStatus
%s%s
\n') fp.write(HTML_END) if __name__ == '__main__': main()