add_mirror_repos.py 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import os
  2. # 1. Update INSTALL_WSL.md
  3. file1 = "INSTALL_WSL.md"
  4. if os.path.exists(file1):
  5. with open(file1, "r", encoding="utf-8", errors="replace") as f:
  6. content = f.read()
  7. old_clone_block = """### Step 2: Clone the Git Repository
  8. Run the following commands inside your WSL Ubuntu home directory to clone the project:
  9. ```bash
  10. git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git
  11. cd LocalFoodAI_lanfr144
  12. ```"""
  13. new_clone_block = """### Step 2: Clone the Git Repository
  14. Run the following commands inside your WSL Ubuntu home directory to clone the project:
  15. **Primary Repository (Internal Network)**:
  16. ```bash
  17. git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git
  18. cd LocalFoodAI_lanfr144
  19. ```
  20. **Alternative Repository (Worldwide Access - Clone of the Primary)**:
  21. ```bash
  22. git clone https://github.com/lanfr144/LocalFoodAI_lanfr144.git
  23. cd LocalFoodAI_lanfr144
  24. ```"""
  25. content = content.replace(old_clone_block, new_clone_block)
  26. with open(file1, "w", encoding="utf-8") as f:
  27. f.write(content)
  28. print("Updated INSTALL_WSL.md with mirror repositories.")
  29. # 2. Update generate_docs.py
  30. file2 = "generate_docs.py"
  31. if os.path.exists(file2):
  32. with open(file2, "r", encoding="utf-8", errors="replace") as f:
  33. content = f.read()
  34. # Update Installation_Guide.md section in generate_docs.py
  35. old_install_repos = """There are two repositories configured for this project:
  36. - Production Repository: `https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git`
  37. - GitHub Mirror (Clone): `https://github.com/lanfr144/LocalFoodAI_lanfr144`"""
  38. new_install_repos = """There are two repositories configured for this project:
  39. - Primary Git Repository: `https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git`
  40. - Alternative Git Repository (Worldwide Access - Clone): `https://github.com/lanfr144/LocalFoodAI_lanfr144.git`"""
  41. content = content.replace(old_install_repos, new_install_repos)
  42. # Update Technical_Document.md section in generate_docs.py
  43. old_tech_repos = """- *Online Mode*: `git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git`"""
  44. new_tech_repos = """- *Online Mode (Primary)*: `git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git`
  45. - *Online Mode (Alternative/Worldwide)*: `git clone https://github.com/lanfr144/LocalFoodAI_lanfr144.git`"""
  46. content = content.replace(old_tech_repos, new_tech_repos)
  47. with open(file2, "w", encoding="utf-8") as f:
  48. f.write(content)
  49. print("Updated generate_docs.py with mirror repositories.")
  50. # 3. Update README.md
  51. file3 = "README.md"
  52. if os.path.exists(file3):
  53. with open(file3, "r", encoding="utf-8", errors="replace") as f:
  54. content = f.read()
  55. old_readme_repos = """2. **Branch Checkout & App Setup (WSL Environment)**:
  56. Navigate to the repository home directory inside WSL:
  57. ```bash
  58. cd ~
  59. git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git
  60. cd LocalFoodAI_lanfr144"""
  61. new_readme_repos = """2. **Branch Checkout & App Setup (WSL Environment)**:
  62. Navigate to the repository home directory inside WSL:
  63. ```bash
  64. cd ~
  65. # Option A: Clone from the Primary Repository (Internal Network)
  66. git clone https://git.btshub.lu/lanfr/LocalFoodAI_lanfr144.git
  67. # Option B: Clone from the Alternative Repository (Worldwide Access - Clone)
  68. # git clone https://github.com/lanfr144/LocalFoodAI_lanfr144.git
  69. cd LocalFoodAI_lanfr144"""
  70. content = content.replace(old_readme_repos, new_readme_repos)
  71. with open(file3, "w", encoding="utf-8") as f:
  72. f.write(content)
  73. print("Updated README.md with mirror repositories.")