Download scripts/study_sources.py from Websterfly/Ai-detector-websterfly: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/Websterfly/Ai-detector-websterfly/resolve/main/scripts/study_sources.py
- Command line
-
hf download hf://spaces/Websterfly/Ai-detector-websterfly/scripts/study_sources.py
-
curl -L -o study_sources.py https://huggingface.co/spaces/Websterfly/Ai-detector-websterfly/resolve/main/scripts/study_sources.py
1.15 kB
| """Clone and extract reviewed-source candidates into a new isolated research folder. | |
| Does not execute cloned source or modify global git configuration. | |
| """ | |
| import json,subprocess | |
| from pathlib import Path | |
| ROOT=Path(__file__).resolve().parents[1] | |
| for source in json.loads((ROOT/'RESEARCH_SOURCES.json').read_text()): | |
| key=source['repo'].split('/')[-1].lower();target=ROOT/'work/upstream'/key | |
| if not target.exists():subprocess.run(['git','clone','--filter=blob:none','--no-checkout','https://github.com/'+source['repo']+'.git',str(target)],check=True) | |
| subprocess.run(['git','-C',str(target),'fetch','--depth','1','origin',source['commit']],check=True) | |
| files=subprocess.check_output(['git','-C',str(target),'ls-tree','--name-only','-r',source['commit']],text=True).splitlines() | |
| for filename in files: | |
| if not filename.endswith(('.py','.md','.toml')) and 'LICENSE' not in filename:continue | |
| body=subprocess.check_output(['git','-C',str(target),'show',source['commit']+':'+filename]) | |
| destination=target/filename;destination.parent.mkdir(parents=True,exist_ok=True);destination.write_bytes(body) | |
| print('Source ready',source['repo'],source['commit']) | |