Commit 94ec7417 authored by Aurel's avatar Aurel

add a method which returns the list of modified block

make some variables global


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37859 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0e6b1b99
......@@ -42,6 +42,10 @@ from xml.sax.saxutils import escape
NBSP = ' '
NBSP_TAB = NBSP*8
NO_DIFF_COLOR = 'white'
MODIFIED_DIFF_COLOR = 'rgb(253, 228, 6);'#light orange
DELETED_DIFF_COLOR = 'rgb(253, 117, 74);'#light red
ADDITION_DIFF_COLOR = 'rgb(83, 253, 74);'#light green
class DiffFile:
"""
......@@ -142,13 +146,30 @@ class DiffFile:
html_list.append('''</tbody></table><br/>''')
return '\n'.join(html_list)
def getModifiedBlockList(self):
"""
Return a list of modified blocks
List contains tuples (old_modified_code, new_modified_code)
"""
if self.binary:
return []
block_list = []
for child in self.children:
old_line_list = [x[0].strip() for x in child.getOldCodeList()
if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR]
new_line_list = [x[0].strip() for x in child.getNewCodeList()
if x[0] is not None and x[1] == MODIFIED_DIFF_COLOR]
block_list.append((old_line_list, new_line_list))
return block_list
class CodeBlock:
"""
A code block contains several SubCodeBlocks
Members :
- old_line : line in old code (before modif)
- new line : line in new code (after modif)
Methods :
- getOldCodeList() : return code before modif
- getNewCodeList() : return code after modif
......@@ -212,13 +233,13 @@ class SubCodeBlock:
self.new_code_length = self._getNewCodeLength()
# Choosing background color
if self.modification == 'none':
self.color = 'white'
self.color = NO_DIFF_COLOR
elif self.modification == 'change':
self.color = 'rgb(253, 228, 6);'#light orange
self.color = MODIFIED_DIFF_COLOR
elif self.modification == 'deletion':
self.color = 'rgb(253, 117, 74);'#light red
self.color = DELETED_DIFF_COLOR
else: # addition
self.color = 'rgb(83, 253, 74);'#light green
self.color = ADDITION_DIFF_COLOR
def _getModif(self):
""" Return type of modification :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment