Files
podman-mvp/collect_code.py

39 lines
1.5 KiB
Python

import os
# Bestanden of mappen die we NIET willen zien
EXCLUDE_DIRS = {'.git', 'node_modules', '__pycache__', 'venv', '.next', 'dist', 'build'}
EXCLUDE_FILES = {'collect_code.py', 'project_context.txt', 'package-lock.json', '.DS_Store'}
# Welke bestandstypes we wel willen verzamelen
INCLUDE_EXTENSIONS = {'.js', '.jsx', '.ts', '.tsx', '.py', '.html', '.css', '.json'}
def collect_code():
output_file = "project_context.txt"
with open(output_file, "w", encoding="utf-8") as f:
for root, dirs, files in os.walk("."):
# Filter uitgesloten mappen
dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS]
for file in files:
if file in EXCLUDE_FILES:
continue
ext = os.path.splitext(file)[1]
if ext in INCLUDE_EXTENSIONS:
full_path = os.path.join(root, file)
f.write(f"\n{'='*50}\n")
f.write(f"FILE: {full_path}\n")
f.write(f"{'='*50}\n\n")
try:
with open(full_path, "r", encoding="utf-8") as code_file:
f.write(code_file.read())
except Exception as e:
f.write(f"Fout bij lezen bestand: {e}")
f.write("\n")
print(f"Klaar! Alle code staat in {output_file}")
if __name__ == "__main__":
collect_code()