19 lines
711 B
Python
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()
|