Method: difflib.HtmlDiff._convert_flags
Calls: 17, Exceptions: 0, Paths: 4Back
Path 1: 13 calls (0.76)
['
['
[False, True, True, True, True, True] (5) [False, False, False, False, False, True, True, False, True, True, True, True, True, True, False, True, True...
False (8) True (5)
5 (10) 0 (2) 6 (1)
tuple (13)
1def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): 2 """Makes list of "next" links""" 3 4 # all anchor names will be generated using the unique "to" prefix 5 toprefix = self._prefix[1] 6 7 # process change flags, generating middle column of next anchors/links 8 next_id = ['']*len(flaglist) 9 next_href = ['']*len(flaglist) 10 num_chg, in_change = 0, False 11 last = 0 12 for i,flag in enumerate(flaglist): 13 if flag: 14 if not in_change: 15 in_change = True 16 last = i 17 # at the beginning of a change, drop an anchor a few lines 18 # (the context lines) before the change for the previous 19 # link 20 i = max([0,i-numlines]) 21 next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) 22 # at the beginning of a change, drop a link to the next 23 # change 24 num_chg += 1 25 next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % ( 26 toprefix,num_chg) 27 else: 28 in_change = False 29 # check for cases where there is no content to avoid exceptions 30 if not flaglist: 31 flaglist = [False] 32 next_id = [''] 33 next_href = [''] 34 last = 0 35 if context: 36 fromlist = ['<td></td><td> No Differences Found </td>'] 37 tolist = fromlist 38 else: 39 fromlist = tolist = ['<td></td><td> Empty File </td>'] 40 # if not a change on first line, drop a link 41 if not flaglist[0]: 42 next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix 43 # redo the last link to link to the top 44 next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix) 45 46 return fromlist,tolist,flaglist,next_href,next_id
Path 2: 2 calls (0.12)
[] (2)
[] (2)
[] (2)
True (2)
5 (2)
tuple (2)
1def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): 2 """Makes list of "next" links""" 3 4 # all anchor names will be generated using the unique "to" prefix 5 toprefix = self._prefix[1] 6 7 # process change flags, generating middle column of next anchors/links 8 next_id = ['']*len(flaglist) 9 next_href = ['']*len(flaglist) 10 num_chg, in_change = 0, False 11 last = 0 12 for i,flag in enumerate(flaglist): 13 if flag: 14 if not in_change: 15 in_change = True 16 last = i 17 # at the beginning of a change, drop an anchor a few lines 18 # (the context lines) before the change for the previous 19 # link 20 i = max([0,i-numlines]) 21 next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) 22 # at the beginning of a change, drop a link to the next 23 # change 24 num_chg += 1 25 next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % ( 26 toprefix,num_chg) 27 else: 28 in_change = False 29 # check for cases where there is no content to avoid exceptions 30 if not flaglist: 31 flaglist = [False] 32 next_id = [''] 33 next_href = [''] 34 last = 0 35 if context: 36 fromlist = ['<td></td><td> No Differences Found </td>'] 37 tolist = fromlist 38 else: 39 fromlist = tolist = ['<td></td><td> Empty File </td>'] 40 # if not a change on first line, drop a link 41 if not flaglist[0]: 42 next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix 43 # redo the last link to link to the top 44 next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix) 45 46 return fromlist,tolist,flaglist,next_href,next_id
Path 3: 1 calls (0.06)
['
['
[False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, Fa...
False (1)
5 (1)
tuple (1)
1def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): 2 """Makes list of "next" links""" 3 4 # all anchor names will be generated using the unique "to" prefix 5 toprefix = self._prefix[1] 6 7 # process change flags, generating middle column of next anchors/links 8 next_id = ['']*len(flaglist) 9 next_href = ['']*len(flaglist) 10 num_chg, in_change = 0, False 11 last = 0 12 for i,flag in enumerate(flaglist): 13 if flag: 14 if not in_change: 15 in_change = True 16 last = i 17 # at the beginning of a change, drop an anchor a few lines 18 # (the context lines) before the change for the previous 19 # link 20 i = max([0,i-numlines]) 21 next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) 22 # at the beginning of a change, drop a link to the next 23 # change 24 num_chg += 1 25 next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % ( 26 toprefix,num_chg) 27 else: 28 in_change = False 29 # check for cases where there is no content to avoid exceptions 30 if not flaglist: 31 flaglist = [False] 32 next_id = [''] 33 next_href = [''] 34 last = 0 35 if context: 36 fromlist = ['<td></td><td> No Differences Found </td>'] 37 tolist = fromlist 38 else: 39 fromlist = tolist = ['<td></td><td> Empty File </td>'] 40 # if not a change on first line, drop a link 41 if not flaglist[0]: 42 next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix 43 # redo the last link to link to the top 44 next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix) 45 46 return fromlist,tolist,flaglist,next_href,next_id
Path 4: 1 calls (0.06)
[] (1)
[] (1)
[] (1)
False (1)
5 (1)
tuple (1)
1def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): 2 """Makes list of "next" links""" 3 4 # all anchor names will be generated using the unique "to" prefix 5 toprefix = self._prefix[1] 6 7 # process change flags, generating middle column of next anchors/links 8 next_id = ['']*len(flaglist) 9 next_href = ['']*len(flaglist) 10 num_chg, in_change = 0, False 11 last = 0 12 for i,flag in enumerate(flaglist): 13 if flag: 14 if not in_change: 15 in_change = True 16 last = i 17 # at the beginning of a change, drop an anchor a few lines 18 # (the context lines) before the change for the previous 19 # link 20 i = max([0,i-numlines]) 21 next_id[i] = ' id="difflib_chg_%s_%d"' % (toprefix,num_chg) 22 # at the beginning of a change, drop a link to the next 23 # change 24 num_chg += 1 25 next_href[last] = '<a href="#difflib_chg_%s_%d">n</a>' % ( 26 toprefix,num_chg) 27 else: 28 in_change = False 29 # check for cases where there is no content to avoid exceptions 30 if not flaglist: 31 flaglist = [False] 32 next_id = [''] 33 next_href = [''] 34 last = 0 35 if context: 36 fromlist = ['<td></td><td> No Differences Found </td>'] 37 tolist = fromlist 38 else: 39 fromlist = tolist = ['<td></td><td> Empty File </td>'] 40 # if not a change on first line, drop a link 41 if not flaglist[0]: 42 next_href[0] = '<a href="#difflib_chg_%s_0">f</a>' % toprefix 43 # redo the last link to link to the top 44 next_href[last] = '<a href="#difflib_chg_%s_top">t</a>' % (toprefix) 45 46 return fromlist,tolist,flaglist,next_href,next_id