fix(b09-print): 도면 영역 이어 붙임 — 초안 router 가 스스로 단 /api/projects 머리를 사본 길에서 떼고 끼움(앞머리 두 번 겹침 없앰) · 못 넣은 그림 수 알림 (302-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfHKQs7J3hQELKMWQMUJEy
This commit is contained in:
2026-10-13 08:06:32 +09:00
co-authored by Claude Opus 5.5
parent feea843595
commit a53b499878
3 changed files with 45 additions and 4 deletions
+12 -2
View File
@@ -29,6 +29,7 @@
from __future__ import annotations
import asyncio
import copy
import importlib
import logging
from pathlib import Path
@@ -347,11 +348,20 @@ router.include_router(quotes_router)
# 302 초안 길(draft/*_Router.py 의 router · 폴더째 지우면 길도 없음) — 같은 머리 · 같은 권한
def include_drafts(target: APIRouter, folder: Path, package: str) -> list[str]:
"""folder 의 *_Router.py 마다 router 를 끼움 → 끼운 파일 이름(못 읽은 초안은 건너뜀)."""
"""folder 의 *_Router.py 마다 router 를 끼움 → 끼운 파일 이름(못 읽은 초안은 건너뜀).
초안이 같은 머리(/api/projects)를 스스로 달았으면 떼고 끼움 — 머리가 두 번 붙지 않게."""
done = []
for path in sorted(folder.glob("*_Router.py")):
try:
target.include_router(importlib.import_module(f"{package}.{path.stem}").router)
draft = importlib.import_module(f"{package}.{path.stem}").router
if target.prefix and draft.prefix.startswith(target.prefix):
# 길은 만들 때 머리가 박힘 — 사본 길에서 떼어 냄(원본은 앱에 바로 붙일 때 그대로)
shim, cut = copy.copy(draft), len(target.prefix)
shim.routes = [copy.copy(route) for route in draft.routes]
for route in shim.routes:
route.path = route.path[cut:]
draft = shim
target.include_router(draft)
done.append(path.stem)
except (ImportError, AttributeError) as error: # 한 초안이 막혀도 B09 는 뜸
logging.getLogger(__name__).warning("초안 길 %s 못 읽음 — %s", path.name, error)