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

Method _convert_flags

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

Makes list of "next" links

(self,fromlist,tolist,flaglist,context,numlines)

Source from the content-addressed store, hash-verified

1891 self._prefix = [fromprefix,toprefix]
1892
1893 def _convert_flags(self,fromlist,tolist,flaglist,context,numlines):
1894 """Makes list of "next" links"""
1895
1896 # all anchor names will be generated using the unique "to" prefix
1897 toprefix = self._prefix[1]
1898
1899 # process change flags, generating middle column of next anchors/links
1900 next_id = ['']*len(flaglist)
1901 next_href = ['']*len(flaglist)
1902 num_chg, in_change = 0, False
1903 last = 0
1904 for i,flag in enumerate(flaglist):
1905 if flag:
1906 if not in_change:
1907 in_change = True
1908 last = i
1909 # at the beginning of a change, drop an anchor a few lines
1910 # (the context lines) before the change for the previous
1911 # link
1912 i = max([0,i-numlines])
1913 next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg)
1914 # at the beginning of a change, drop a link to the next
1915 # change
1916 num_chg += 1
1917 next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % (
1918 toprefix,num_chg)
1919 else:
1920 in_change = False
1921 # check for cases where there is no content to avoid exceptions
1922 if not flaglist:
1923 flaglist = [False]
1924 next_id = ['']
1925 next_href = ['']
1926 last = 0
1927 if context:
1928 fromlist = ['<td></td><td>&nbsp;No Differences Found&nbsp;</td>']
1929 tolist = fromlist
1930 else:
1931 fromlist = tolist = ['<td></td><td>&nbsp;Empty File&nbsp;</td>']
1932 # if not a change on first line, drop a link
1933 if not flaglist[0]:
1934 next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix
1935 # redo the last link to link to the top
1936 next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix)
1937
1938 return fromlist,tolist,flaglist,next_href,next_id
1939
1940 def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False,
1941 numlines=5):

Callers 1

make_tableMethod · 0.95

Calls 2

enumerateFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected