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)
评论列表
文章目录