Buckets:

download
raw
1.95 kB
import os
# ================== CONFIG ==================
PROJECT_ROOT = "." # Project root directory
OUTPUT_FILE = "project_code.txt" # Output code file
# Directories to skip
EXCLUDE_DIRS = {
".git", "__pycache__", "venv", ".venv",
"env", "node_modules", ".idea", ".vscode",
}
# Python files not to export
EXCLUDE_FILES = {
"__init__.py", "export_code.py",
}
# Extra files to export (non-.py)
EXTRA_FILES = {
"requirements.txt",
"docker-compose.yml",
"Dockerfile",
"env.example",
"pyproject.toml"
}
# =============================================
def should_skip_dir(dir_name: str) -> bool:
return dir_name in EXCLUDE_DIRS
def should_export_file(file_name: str) -> bool:
# Export .py files (except excluded)
if file_name.endswith(".py"):
return file_name not in EXCLUDE_FILES
# Export extra files
if file_name in EXTRA_FILES:
return True
return False
def export_project_code():
with open(OUTPUT_FILE, "w", encoding="utf-8") as out:
for root, dirs, files in os.walk(PROJECT_ROOT):
# Skip directories that should not be traversed
dirs[:] = [d for d in dirs if not should_skip_dir(d)]
for file in files:
if not should_export_file(file):
continue
file_path = os.path.join(root, file)
rel_path = os.path.relpath(file_path, PROJECT_ROOT)
out.write("\n" + "=" * 80 + "\n")
out.write(f"# FILE: {rel_path}\n")
out.write("=" * 80 + "\n\n")
try:
with open(file_path, "r", encoding="utf-8") as f:
out.write(f.read())
except Exception as e:
out.write(f"# ERROR reading file: {e}\n")
print(f"✅ Exported all code to file: {OUTPUT_FILE}")
if __name__ == "__main__":
export_project_code()

Xet Storage Details

Size:
1.95 kB
·
Xet hash:
54f5c0586c86c238461ff01ce44fe2d7f90c7e3d0c5df4647c32386172d2994f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.