aibilly_backend_code/fix_routes_async.py
laxmanhalaki b793ac859a
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / build (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-production (push) Has been cancelled
modification done to up the project
2026-03-12 20:52:08 +05:30

19 lines
711 B
Python

import os
from pathlib import Path
import re
def fix_routes():
routes_dir = Path("src/routes")
for route_file in routes_dir.glob("*_routes.py"):
content = route_file.read_text(encoding="utf-8")
# Add await to crud.* calls
# Matches: db_user = crud.get_by_id(user_id) -> await crud.get_by_id(user_id)
# Matches: return crud.create(user_in) -> return await crud.create(user_in)
# We need to be careful not to double await
content = re.sub(r"(?<!await\s)crud\.(\w+)\(", r"await crud.\1(", content)
route_file.write_text(content, encoding="utf-8")
print(f"Fixed async/await in {route_file.name}")
if __name__ == "__main__":
fix_routes()