Download verify_files.py from autotrust/TTS-V8: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/autotrust/TTS-V8/resolve/main/verify_files.py
- Command line
-
hf download hf://autotrust/TTS-V8/verify_files.py
-
curl -L -o verify_files.py https://huggingface.co/autotrust/TTS-V8/resolve/main/verify_files.py
1.07 kB
| #!/usr/bin/env python3 | |
| """Stream-check every file listed in a complete TTS-V4 delivery.""" | |
| import argparse | |
| import hashlib | |
| from pathlib import Path | |
| def main(): | |
| parser=argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--directory',type=Path,default=Path(__file__).resolve().parent) | |
| args=parser.parse_args() | |
| root=args.directory.resolve() | |
| manifest=root/'SHA256SUMS' | |
| checked=0 | |
| for line in manifest.read_text().splitlines(): | |
| expected,name=line.split(' ',1) | |
| path=(root/name).resolve() | |
| if not path.is_relative_to(root) or not path.is_file(): | |
| raise SystemExit(f'缺少文件或非法路径:{name}') | |
| digest=hashlib.sha256() | |
| with path.open('rb') as handle: | |
| for block in iter(lambda:handle.read(8*1024*1024),b''): | |
| digest.update(block) | |
| if digest.hexdigest()!=expected: | |
| raise SystemExit(f'校验失败:{name}') | |
| checked+=1 | |
| print(f'全部{checked}个文件SHA-256校验通过:{root}') | |
| if __name__=='__main__': | |
| main() | |