# -*- coding: utf-8 -*-
"""
운영 초안 생성 복구 패치 3차
- 단지 주소 검색 시에만 동/호 제거
- DB 저장값, 본문 제목, 대표이미지용 complex/dong 정보는 기존 그대로 유지

목표:
  하이뷰더파크 1동  -> 주소 검색용: 하이뷰더파크
  포레나천안두정 106동 -> 주소 검색용: 포레나천안두정
  해밀1단지마스터힐스 144동 -> 주소 검색용: 해밀1단지마스터힐스

사용:
  cd /d D:\honghee\blog_api
  python tools\patch_complex_address_search_name_clean.py
"""

from pathlib import Path
from datetime import datetime
import re

ROOT = Path(__file__).resolve().parents[1]
TARGET = ROOT / "jobs" / "generate_blog_drafts.py"

if not TARGET.exists():
    raise FileNotFoundError(TARGET)

text = TARGET.read_text(encoding="utf-8", errors="replace")

backup = TARGET.with_name(
    f"generate_blog_drafts_backup_searchname_clean_{datetime.now().strftime('%Y%m%d_%H%M%S')}.py"
)
backup.write_text(text, encoding="utf-8")
print("[BACKUP]", backup)

helper = r