Makes list of "next" links
(self,fromlist,tolist,flaglist,context,numlines)
| 1946 | self._prefix = [fromprefix,toprefix] |
| 1947 | |
| 1948 | def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): |
| 1949 | """Makes list of "next" links""" |
| 1950 | |
| 1951 | # all anchor names will be generated using the unique "to" prefix |
| 1952 | toprefix = self._prefix[1] |
| 1953 | |
| 1954 | # process change flags, generating middle column of next anchors/links |
| 1955 | next_id = ['']*len(flaglist) |
| 1956 | next_href = ['']*len(flaglist) |
| 1957 | num_chg, in_change = 0, False |
| 1958 | last = 0 |
| 1959 | for i,flag in enumerate(flaglist): |
| 1960 | if flag: |
| 1961 | if not in_change: |
| 1962 | in_change = True |
| 1963 | last = i |
| 1964 | # at the beginning of a change, drop an anchor a few lines |
| 1965 | # (the context lines) before the change for the previous |
| 1966 | # link |
| 1967 | i = max([0,i-numlines]) |
| 1968 | next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) |
| 1969 | # at the beginning of a change, drop a link to the next |
| 1970 | # change |
| 1971 | num_chg += 1 |
| 1972 | next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % ( |
| 1973 | toprefix,num_chg) |
| 1974 | else: |
| 1975 | in_change = False |
| 1976 | # check for cases where there is no content to avoid exceptions |
| 1977 | if not flaglist: |
| 1978 | flaglist = [False] |
| 1979 | next_id = [''] |
| 1980 | next_href = [''] |
| 1981 | last = 0 |
| 1982 | if context: |
| 1983 | fromlist = ['<td></td><td> No Differences Found </td>'] |
| 1984 | tolist = fromlist |
| 1985 | else: |
| 1986 | fromlist = tolist = ['<td></td><td> Empty File </td>'] |
| 1987 | # if not a change on first line, drop a link |
| 1988 | if not flaglist[0]: |
| 1989 | next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix |
| 1990 | # redo the last link to link to the top |
| 1991 | next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix) |
| 1992 | |
| 1993 | return fromlist,tolist,flaglist,next_href,next_id |
| 1994 | |
| 1995 | def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False, |
| 1996 | numlines=5): |