#
# Authors: Olivier MATZ <zer0@droids-corp.org>
# Alan De Smet <adesmet@cs.wisc.edu>
+# Sergey Satskiy <sergey.satskiy@gmail.com>
#
# Inspired by diff2html.rb from Dave Burt <dave (at) burt.id.au>
# (mainly for html theme)
# 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
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
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 "
+ input_stream = StringIO.StringIO(txt)
+ output_stream = StringIO.StringIO()
+ parse_input(input_stream, output_stream, exclude_headers, show_hunk_infos)
+ return output_stream.getvalue()
+
if __name__ == "__main__":
main()