def output_file_lists(self): out = "" while not self.__fileChanges.isEndReached(): line = self.__fileChanges.cleanCurrentLine() m = re.match("^(.)(.).+", line) if m: filename = re.sub("^(.)(.)\s+", "", line) self.__files[m.group(1)].append(filename) if m.group(2) != " " and m.group(1) != "_": self.__files["_"].append(filename) self.__fileChanges.goToNextLine() for t in ["U", "A", "D", "_"]: if not self.__files[t]: continue tag = HtmlTag("h3") tag.setText(self.__changeCodes[t]) out += tag.toHtml(TagMode.CLOSED) + "\n" + HtmlTag("ul").toHtml() + "\n" for filename in self.__files[t]: f = self.html_escape(filename) if f.endswith("/") and t != "_": # Directories don't link, unless it's a prop change li = HtmlTag("li") li.setText(f) out += li.toHtml(TagMode.CLOSED) + "\n" else: html_id = re.sub(r"[^\w_]", r"", f) aTag = HtmlTag("a") aTag.setText(f) aTag.addAttribute("href", "#" + html_id) li = HtmlTag("li") li.setInnerHtml(aTag.toHtml(TagMode.CLOSED)) out += li.toHtml(TagMode.CLOSED) + "\n" out += "</ul>\n\n" return out
def output_formatted_diff(self): length = 0 tag = HtmlTag("h3") tag.setText("Diff") divTag = HtmlTag("div", "patch") divTag.setInnerHtml("\n" + tag.toHtml(TagMode.CLOSED)) out = divTag.toHtml() + "\n" self.__diff.resetCurrentLine() while not self.__diff.isEndReached(): line = self.__diff.cleanCurrentLine() if not line: self.__diff.goToNextLine() continue length += len(line) if self.__isMaxLengthReached(length): out += self.__closeAfterMaxLength() break if self.__diff.isFileChangeLine(): out += self.__handleFileChange() else: out += self.__handleOtherLines() self.__diff.goToNextLine() if self.__inSpan: out += self.__inSpan.getCloseTag() if self.__inDiv: out += HtmlTag.printCloseTag("span") out += HtmlTag.printCloseTag("pre") + "\n" out += HtmlTag.printCloseTag("div") + "\n" out += HtmlTag.printCloseTag("div") + "\n" return out