conda_manager.py 文件源码

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

项目:anaconda-project 作者: Anaconda-Platform 项目源码 文件源码
def _pretty_diff(old_list, new_list, indent):
    diff = list(difflib.ndiff(old_list, new_list))

    # the diff has - lines, + lines, and ? lines
    # the ? lines have the ^ pointing to changed character,
    # which is just noise for these short version strings.
    # the diff also has lines with just whitespace at the
    # front, which are context.

    # remove context lines
    diff = filter(lambda x: x[0] != ' ', diff)
    # remove ? lines
    diff = filter(lambda x: x[0] != '?', diff)

    def indent_more(s):
        if s.startswith("+ "):
            return "+ " + indent + s[2:]
        elif s.startswith("- "):
            return "- " + indent + s[2:]
        else:
            return s  # pragma: no cover # should not be any other kind of lines

    diff = map(indent_more, diff)

    return list(diff)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号