MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / make_table

Method make_table

tools/python-3.11.9-amd64/Lib/difflib.py:1940–2015  ·  view source on GitHub ↗

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

(self,fromlines,tolines,fromdesc='',todesc='',context=False,
                   numlines=5)

Source from the content-addressed store, hash-verified

1938 return fromlist,tolist,flaglist,next_href,next_id
1939
1940 def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
1941 numlines=5):
1942 """Returns HTML table of side by side comparison with change highlights
1943
1944 Arguments:
1945 fromlines -- list of "from" lines
1946 tolines -- list of "to" lines
1947 fromdesc -- "from" file column header string
1948 todesc -- "to" file column header string
1949 context -- set to True for contextual differences (defaults to False
1950 which shows full differences).
1951 numlines -- number of context lines. When context is set True,
1952 controls number of lines displayed before and after the change.
1953 When context is False, controls the number of lines to place
1954 the "next" link anchors before the next change (so click of
1955 "next" link jumps to just before the change).
1956 """
1957
1958 # make unique anchor prefixes so that multiple tables may exist
1959 # on the same page without conflict.
1960 self._make_prefix()
1961
1962 # change tabs to spaces before it gets more difficult after we insert
1963 # markup
1964 fromlines,tolines = self._tab_newline_replace(fromlines,tolines)
1965
1966 # create diffs iterator which generates side by side from/to data
1967 if context:
1968 context_lines = numlines
1969 else:
1970 context_lines = None
1971 diffs = _mdiff(fromlines,tolines,context_lines,linejunk=self._linejunk,
1972 charjunk=self._charjunk)
1973
1974 # set up iterator to wrap lines that exceed desired width
1975 if self._wrapcolumn:
1976 diffs = self._line_wrapper(diffs)
1977
1978 # collect up from/to lines and flags into lists (also format the lines)
1979 fromlist,tolist,flaglist = self._collect_lines(diffs)
1980
1981 # process change flags, generating middle column of next anchors/links
1982 fromlist,tolist,flaglist,next_href,next_id = self._convert_flags(
1983 fromlist,tolist,flaglist,context,numlines)
1984
1985 s = []
1986 fmt = ' <tr><td class="diff_next"%s>%s</td>%s' + \
1987 '<td class="diff_next">%s</td>%s</tr>\n'
1988 for i in range(len(flaglist)):
1989 if flaglist[i] is None:
1990 # mdiff yields None on separator lines skip the bogus ones
1991 # generated for the first line
1992 if i > 0:
1993 s.append(' </tbody> \n <tbody>\n')
1994 else:
1995 s.append( fmt % (next_id[i],next_href[i],fromlist[i],
1996 next_href[i],tolist[i]))
1997 if fromdesc or todesc:

Callers 1

make_fileMethod · 0.95

Calls 9

_make_prefixMethod · 0.95
_tab_newline_replaceMethod · 0.95
_line_wrapperMethod · 0.95
_collect_linesMethod · 0.95
_convert_flagsMethod · 0.95
_mdiffFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected