shape.py 文件源码

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

项目:data 作者: pytube 项目源码 文件源码
def check_render_rest(data_root, verbose=False):
    category_paths, video_paths = get_json_files(data_root)

    file_paths = category_paths + video_paths

    error_by_path = {}
    for file_path in file_paths:
        with open(file_path, encoding='UTF-8') as fp:
            serialized_blob = fp.read()
            re_serialized_blob = json.dumps(
                json.loads(serialized_blob),
                **JSON_FORMAT_KWARGS
            )
            if serialized_blob.strip() != re_serialized_blob.strip():
                error_by_path[file_path] = (serialized_blob, re_serialized_blob)

    if error_by_path:
        for path, blobs in error_by_path.items():
            print('Incorrect serialization order in {}'.format(path), flush=True)
            blobs = tuple(blob.splitlines(keepends=True) for blob in blobs)
            if verbose:
                print(''.join(difflib.ndiff(*blobs)), end="")
        sys.exit(1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号