Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. openTag = """<span style='font-size:1.0em; color: """
  2. openTagEnd = ";font-family: courier, arial, helvetica, sans-serif;'>"
  3. nbsp = '&nbsp;&nbsp;&nbsp;&nbsp;'
  4.  
  5. def _traditional_diff(linesfromDiff, openTag, openTagEnd, nbsp):
  6. lines = []
  7. line_num = 0
  8.  
  9. def updateLine(line_num, color, line):
  10. tabs = line.count('t')
  11. lines.append("%s:%s#%s%s%s%s</span><br>" %
  12. ((repr(line_num), openTag, color, openTagEnd, nbsp*tabs, line)))
  13. return lines
  14.  
  15. for line in linesfromDiff:
  16. if (line.startswith('diff ') or
  17. line.startswith('index ') or
  18. line.startswith('--- ')):
  19. color = "10EDF5"
  20. updateLine(line_num, color, line)
  21. continue
  22.  
  23. if line.startswith('-'):
  24. color = "ff0000"
  25. updateLine(line_num, color, line)
  26. continue
  27.  
  28.  
  29. if line.startswith('+++ '):
  30. color = "07CB14"
  31. updateLine(line_num, color, line)
  32. continue
  33.  
  34. if line.startswith('@@ '):
  35. _, old_nr, new_nr, _ = line.split(' ', 3)
  36. line_num = int(new_nr.split(',')[0])
  37. color = "5753BE"
  38. updateLine(line_num, color, line)
  39. continue
  40.  
  41. if line.startswith('+'):
  42. color = "007900"
  43. updateLine(line_num, color, line)
  44.  
  45. if line.startswith('+') or line.startswith(' '):
  46. line_num += 1
  47.  
  48. return ''.join(lines)
  49.  
  50. <td>
  51.  
  52. </td>
  53.  
  54. <table><tr>%s</tr></table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement