watch.py 文件源码

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

项目:idiot 作者: snare 项目源码 文件源码
def run(self):
        try:
            manifest = yaml.safe_load(self.wd.read('manifest'))
        except:
            log.error("No snapshot found")
            return (False, "no snapshot found")

        fails = []
        for filepath in manifest:
            f = File(filepath)
            s = File(manifest[filepath], parent=self.wd)
            diff = list(difflib.unified_diff(f.content.splitlines(), s.content.splitlines()))
            if len(diff):
                fails.append(filepath)
                log.info("Check for {} failed with diff:")
                log.info("\n".join(diff))

        if len(fails):
            return (False, "the following files have changed: {}".format(', '.join(fails)))
        else:
            return (True, "no files have changed")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号