X-Git-Url: http://git.droids-corp.org/?p=diff2html.git;a=blobdiff_plain;f=diff2html.py;h=337667faadfec6247fb4e14b4736cc3867e8b73a;hp=6e2751e4d7a585f73de28abd6de0fc2ba2ef96d3;hb=dd0649dbd5ba5463535a8a2cb4c2335a78e4fec6;hpb=ad3d66724c62f87c720185bad6f6be71627339de diff --git a/diff2html.py b/diff2html.py index 6e2751e..337667f 100644 --- a/diff2html.py +++ b/diff2html.py @@ -20,6 +20,7 @@ # # Authors: Olivier MATZ # Alan De Smet +# Sergey Satskiy # # Inspired by diff2html.rb from Dave Burt # (mainly for html theme) @@ -32,7 +33,7 @@ # and display those directly. -import sys, re, htmlentitydefs, getopt +import sys, re, htmlentitydefs, getopt, StringIO # minimum line size, we add a zero-sized breakable space every # LINESIZE characters @@ -308,10 +309,12 @@ def parse_input(input_file, output_file, if m: empty_buffer(output_file) file1 = m.groups()[0] - l = input_file.readline() - m = re.match('^\+\+\+ ([^\s]*)', l) - if m: - file2 = m.groups()[0] + while True: + l = input_file.readline() + m = re.match('^\+\+\+ ([^\s]*)', l) + if m: + file2 = m.groups()[0] + break add_filename(file1, file2, output_file) hunk_off1, hunk_size1, hunk_off2, hunk_size2 = 0, 0, 0, 0 continue @@ -419,6 +422,11 @@ def main(): parse_input(input_file, output_file, exclude_headers, show_hunk_infos) +def parse_from_memory(txt, exclude_headers, show_hunk_infos): + " Parses diff from memory and returns a string with html " + stream = StringIO.StringIO(txt) + parse_input(stream, stream, exclude_headers, show_hunk_infos) + return stream.buf if __name__ == "__main__": main()