BIG CLEANUP

This commit is contained in:
Dobromir Popov
2025-08-08 14:58:55 +03:00
parent e39e9ee95a
commit 2b0d2679c6
162 changed files with 455 additions and 42814 deletions

View File

@ -0,0 +1,74 @@
import os
import shutil
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
EXCLUDE_PREFIXES = (
'COBY' + os.sep, # Do not touch COBY subsystem
)
EXCLUDE_FILES = {
'NN' + os.sep + 'training' + os.sep + 'enhanced_realtime_training.py',
}
delete_list_path = ROOT / 'DELETE_CANDIDATES.txt'
deleted_files: list[str] = []
kept_files: list[str] = []
if delete_list_path.exists():
for line in delete_list_path.read_text(encoding='utf-8').splitlines():
rel = line.strip()
if not rel:
continue
# Skip excluded prefixes
if any(rel.startswith(p) for p in EXCLUDE_PREFIXES):
kept_files.append(rel)
continue
# Skip explicitly excluded files
if rel in EXCLUDE_FILES:
kept_files.append(rel)
continue
fp = ROOT / rel
if fp.exists() and fp.is_file():
try:
fp.unlink()
deleted_files.append(rel)
except Exception:
kept_files.append(rel)
# Remove tests directories outside COBY
removed_dirs: list[str] = []
for d in ROOT.rglob('tests'):
try:
rel = str(d.relative_to(ROOT))
except Exception:
continue
if any(rel.startswith(p) for p in EXCLUDE_PREFIXES):
continue
if d.is_dir():
try:
shutil.rmtree(d)
removed_dirs.append(rel)
except Exception:
pass
# Write cleanup log / todo
log_lines = []
log_lines.append('Cleanup run summary:')
log_lines.append(f'- Deleted files: {len(deleted_files)}')
for x in deleted_files[:50]:
log_lines.append(f' - {x}')
if len(deleted_files) > 50:
log_lines.append(f' ... and {len(deleted_files)-50} more')
log_lines.append(f'- Removed test directories: {len(removed_dirs)}')
for x in removed_dirs[:50]:
log_lines.append(f' - {x}')
log_lines.append(f'- Kept (excluded): {len(kept_files)}')
(ROOT / 'CLEANUP_TODO.md').write_text('\n'.join(log_lines), encoding='utf-8')
print(f'Deleted files: {len(deleted_files)}')
print(f'Removed test dirs: {len(removed_dirs)}')
print(f'Kept (excluded): {len(kept_files)}')