#!/usr/bin/python import re, os, sys class STANReporter: def __init__(self, srcpath, path): self.errors = dict() self.warns = dict() self.srcpath = srcpath f = open(path, "r") for l in f.readlines(): self.parse_line(l) f.close() print self.errors def report(self, path): for c in self.errors: self.__output_class_html(path, c) def __output_class_html(self, path, classname): path_to_class = self.srcpath for c in classname.split("."): path_to_class = os.path.join(path_to_class, c) path_to_class += ".java" try: c = open(path_to_class) except Exception: return f = open(os.path.join(path, classname+".html"), "w") f.write("\n") f.write("" + classname + "\n") f.write("

Report for class " + classname + "

") f.write("\n") lineno = 0 for l in c.readlines(): lineno += 1 if lineno % 2: f.write("") else: f.write("") f.write("") if self.errors[classname].has_key(lineno): f.write("") f.write("") else: if lineno % 2: f.write("") else: f.write("") f.write("") f.write("") f.write("
" + str(lineno) + "" + l.replace(' ', ' ') + "" + self.errors[classname][lineno] + "" + l.replace(' ', ' ') + "" + l.replace(' ', ' ') + "
") f.write("\n") f.close() c.close() def parse_line(self, line): m = re.search('\[(.+)]\{(.+)\}\{(.+):(\d+)\} (.+)', line) if m == None: return errtype = m.group(1) if errtype == 'E': if not self.errors.has_key(m.group(2)): self.errors[m.group(2)] = dict() self.errors[m.group(2)][int(m.group(4))] = m.group(5) def main(): if len(sys.argv) < 4: print "Usage :", sys.argv[0], "TRACE_FILE SRC_PATH TARGET_DIR" sys.exit(1) x = STANReporter(sys.argv[2], sys.argv[1]) x.report(sys.argv[3]) if __name__ == "__main__": main()