utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:grical 作者: wikical 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号