[Erp5-report] r37859 aurel - /erp5/trunk/products/ERP5Type/DiffUtils.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Aug 17 11:13:39 CEST 2010
Author: aurel
Date: Tue Aug 17 11:13:35 2010
New Revision: 37859
URL: http://svn.erp5.org?rev=37859&view=rev
Log:
add a method which returns the list of modified block
make some variables global
Modified:
erp5/trunk/products/ERP5Type/DiffUtils.py
Modified: erp5/trunk/products/ERP5Type/DiffUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/DiffUtils.py?rev=37859&r1=37858&r2=37859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/DiffUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/DiffUtils.py [utf8] Tue Aug 17 11:13:35 2010
@@ -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 :
More information about the Erp5-report
mailing list