def text_diff(old_as_text, new_as_text): # {{{1
""" returns a unicode string containing a diff text showing
differences of the utf8 parameters """
old_as_text = smart_unicode( old_as_text ).splitlines()
new_as_text = smart_unicode( new_as_text ).splitlines()
text_diff = unified_diff(
old_as_text, new_as_text, n = 0, lineterm = "" )
# we now delete from the text diff all control lines
# TODO: when the description field of an event contains such lines,
# they will be deleted: avoid it.
text_diff = [line for line in text_diff if not
re.match(r"^---\s*$", line) and not
re.match(r"^\+\+\+\s*$", line) and not
re.match(r"^@@.*@@$", line)]
text_diff = u'\n'.join( text_diff )
return text_diff
评论列表
文章目录