Datasets:
File size: 893 Bytes
e4b121b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from pathlib import Path
import json
root=Path(__file__).resolve().parent
old='/home/donghongzhou/project/SP-Transient-retrain'
previous=root/'.relocation.json'
origins=[old]
if previous.exists(): origins.append(json.loads(previous.read_text())['root'])
count=0
for base in [root/'stb_minimal_20261017',root/'experiments',root/'config']:
for p in base.rglob('*'):
if not p.is_file() or p.suffix.lower() not in {'.py','.ini','.yaml','.yml','.json'}: continue
try: text=p.read_text(encoding='utf-8')
except UnicodeError: continue
updated=text
for source in origins: updated=updated.replace(source,str(root))
if updated!=text:
temp=p.with_name(p.name+'.relocate.tmp'); temp.write_text(updated,encoding='utf-8'); temp.replace(p); count+=1
previous.write_text(json.dumps({'root':str(root)}))
print('Relocated',count,'files to',root)
|