-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcleanup.py
More file actions
88 lines (70 loc) · 2.47 KB
/
cleanup.py
File metadata and controls
88 lines (70 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
"""
Cleanup Script for Portfolio Enrichment System
Removes unnecessary files and resets the system for fresh runs.
"""
import os
def cleanup_project():
"""
Remove all generated and temporary files to reset system state.
Cleans up logs, cache files, state files, and output files while
preserving essential source code and configuration files.
"""
print("🧹 Starting Portfolio Enrichment System Cleanup...")
# Essential files to keep
essential_files = {
"core_functions.py",
"task_a_csv_reader.py",
"task_b_symbol_resolver.py",
"task_c_name_resolver.py",
"task_d_csv_writer.py",
"orchestrator.py",
"Sample_Portfolio_Holdings.csv",
"requirements.txt",
".env",
".gitignore",
"README.md",
"cleanup.py",
"AGENT_INITIAL_DRAFT.md",
}
# Get all files in current directory
all_files = []
for item in os.listdir("."):
if os.path.isfile(item):
all_files.append(item)
removed_count = 0
print(f"\n🔍 Scanning directory for non-essential files...")
for file_path in all_files:
if file_path not in essential_files:
try:
os.remove(file_path)
print(f" ✅ Removed: {file_path}")
removed_count += 1
except Exception as e:
print(f" ⚠️ Could not remove {file_path}: {e}")
else:
print(f" 🔒 Keeping essential file: {file_path}")
# Also remove Python cache directories
cache_dirs = ["__pycache__"]
for cache_dir in cache_dirs:
if os.path.exists(cache_dir) and os.path.isdir(cache_dir):
try:
import shutil
shutil.rmtree(cache_dir)
print(f" ✅ Removed directory: {cache_dir}")
removed_count += 1
except Exception as e:
print(f" ⚠️ Could not remove {cache_dir}: {e}")
print(f"\n📊 Cleanup Summary:")
print(f" 🗑️ Files removed: {removed_count}")
# Show remaining essential files
print(f"\n📁 Essential Files Remaining:")
for file in sorted(essential_files):
if os.path.exists(file):
print(f" ✅ {file}")
else:
print(f" ❌ {file} (missing)")
print(f"\n🎯 System ready for fresh run!")
print(f" Next: python orchestrator.py")
if __name__ == "__main__":
cleanup_project()