Returns HTML table of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file column header string todesc -- "to" file column header string context -- set to Tru
(self,fromlines,tolines,fromdesc='',todesc='',context=False,
numlines=5)
| 1993 | return fromlist,tolist,flaglist,next_href,next_id |
| 1994 | |
| 1995 | def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False, |
| 1996 | numlines=5): |
| 1997 | """Returns HTML table of side by side comparison with change highlights |
| 1998 | |
| 1999 | Arguments: |
| 2000 | fromlines -- list of "from" lines |
| 2001 | tolines -- list of "to" lines |
| 2002 | fromdesc -- "from" file column header string |
| 2003 | todesc -- "to" file column header string |
| 2004 | context -- set to True for contextual differences (defaults to False |
| 2005 | which shows full differences). |
| 2006 | numlines -- number of context lines. When context is set True, |
| 2007 | controls number of lines displayed before and after the change. |
| 2008 | When context is False, controls the number of lines to place |
| 2009 | the "next" link anchors before the next change (so click of |
| 2010 | "next" link jumps to just before the change). |
| 2011 | """ |
| 2012 | |
| 2013 | # make unique anchor prefixes so that multiple tables may exist |
| 2014 | # on the same page without conflict. |
| 2015 | self._make_prefix() |
| 2016 | |
| 2017 | # change tabs to spaces before it gets more difficult after we insert |
| 2018 | # markup |
| 2019 | fromlines,tolines = self._tab_newline_replace(fromlines,tolines) |
| 2020 | |
| 2021 | # create diffs iterator which generates side by side from/to data |
| 2022 | if context: |
| 2023 | context_lines = numlines |
| 2024 | else: |
| 2025 | context_lines = None |
| 2026 | diffs = _mdiff(fromlines,tolines,context_lines,linejunk=self._linejunk, |
| 2027 | charjunk=self._charjunk) |
| 2028 | |
| 2029 | # set up iterator to wrap lines that exceed desired width |
| 2030 | if self._wrapcolumn: |
| 2031 | diffs = self._line_wrapper(diffs) |
| 2032 | |
| 2033 | # collect up from/to lines and flags into lists (also format the lines) |
| 2034 | fromlist,tolist,flaglist = self._collect_lines(diffs) |
| 2035 | |
| 2036 | # process change flags, generating middle column of next anchors/links |
| 2037 | fromlist,tolist,flaglist,next_href,next_id = self._convert_flags( |
| 2038 | fromlist,tolist,flaglist,context,numlines) |
| 2039 | |
| 2040 | s = [] |
| 2041 | fmt = ' <tr><td class="diff_next"%s>%s</td>%s' + \ |
| 2042 | '<td class="diff_next">%s</td>%s</tr>\n' |
| 2043 | for i in range(len(flaglist)): |
| 2044 | if flaglist[i] is None: |
| 2045 | # mdiff yields None on separator lines skip the bogus ones |
| 2046 | # generated for the first line |
| 2047 | if i > 0: |
| 2048 | s.append(' </tbody> \n <tbody>\n') |
| 2049 | else: |
| 2050 | s.append( fmt % (next_id[i],next_href[i],fromlist[i], |
| 2051 | next_href[i],tolist[i])) |
| 2052 | if fromdesc or todesc: |