zip_project.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import zipfile
  3. def zip_project():
  4. output_zip = r"./LocalFoodAI_lanfr144.zip"
  5. base_dir = r"."
  6. food_dir = os.path.join(base_dir, "Food")
  7. print(f"Creating ZIP archive at: {output_zip}")
  8. with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED, allowZip64=True ) as zipf:
  9. # 1. Zip parent folder planning documents
  10. parent_docs = [
  11. "todo.docx",
  12. "domainproject.pdf",
  13. "BTS-AI DOPRO Course Catalogue.pdf",
  14. "The_Scrum_Master_Training_Manual_A_Guide.pdf"
  15. ]
  16. print("Archiving parent planning and project documents...")
  17. for doc in parent_docs:
  18. doc_path = os.path.join(base_dir, doc)
  19. if os.path.exists(doc_path):
  20. # Write to root of the ZIP
  21. zipf.write(doc_path, arcname=doc)
  22. print(f" Added: {doc}")
  23. else:
  24. print(f" WARNING: {doc} not found, skipping.")
  25. # 2. Zip the entire Food directory recursively
  26. print("Archiving Food codebase (excluding .venv and caches)...")
  27. exclude_dirs = {".venv", "__pycache__", ".git"}
  28. for root, dirs, files in os.walk(food_dir):
  29. # Prune directories in-place to exclude .venv, .git, and __pycache__
  30. dirs[:] = [d for d in dirs if d not in exclude_dirs]
  31. for file in files:
  32. # Do not zip the temporary scratch scripts or ZIP itself if created there
  33. file_path = os.path.join(root, file)
  34. # Compute relative path inside the zip file
  35. rel_path = os.path.relpath(file_path, base_dir)
  36. zipf.write(file_path, arcname=rel_path)
  37. print("ZIP archive successfully completed!")
  38. if __name__ == "__main__":
  39. zip_project()