Datasets:
Download scripts/restore_file_modes.py from CrossSWE/CrossSWE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/restore_file_modes.py
- Command line
-
hf download hf://datasets/CrossSWE/CrossSWE-Bench/scripts/restore_file_modes.py
-
curl -L -o restore_file_modes.py https://huggingface.co/datasets/CrossSWE/CrossSWE-Bench/resolve/main/scripts/restore_file_modes.py
879 Bytes
| """Restore executable bits recorded in the release after HTTP snapshot download.""" | |
| from pathlib import Path | |
| import argparse, json, os | |
| ROOT = Path(__file__).resolve().parents[1] | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--check-only', action='store_true') | |
| args = parser.parse_args() | |
| mapping = json.loads((ROOT / 'data/file-modes.json').read_text()) | |
| changed = [] | |
| for name, mode in mapping.items(): | |
| path = ROOT / name | |
| assert not Path(name).is_absolute() and '..' not in Path(name).parts and path.is_file() and not path.is_symlink() | |
| if path.stat().st_mode & 0o777 != mode: | |
| changed.append(name) | |
| if not args.check_only: | |
| path.chmod(mode) | |
| print(json.dumps({'different_modes' if args.check_only else 'restored_modes':len(changed)})) | |