Merge remote-tracking branch 'origin/sub_laptop_1' into sub_desktop_1

This commit is contained in:
2026-09-20 23:09:58 +09:00
10 changed files with 210 additions and 46 deletions
+10 -8
View File
@@ -350,11 +350,12 @@ def _brief(ref: str, row: dict) -> dict:
}
def _pick_brief(whole, cond: dict) -> dict | None:
"""고르기 조건 줄의 단가 미리보기 — 후보 수와 시험 계산이 쓸 줄(값 열 다섯 포함)."""
def _pick_brief(whole, cond: dict, unit: str | None = None) -> dict | None:
"""고르기 조건 줄의 단가 미리보기 — 후보 수와 시험 계산이 쓸 줄(값 열 다섯 포함).
`unit` = 호표 줄 단위 — 후보를 같은 단위 줄로만 거름."""
try:
keys = cm.mf.candidates(whole, cond, {})
brief = _market_brief(whole.get(cm.mf.pick(whole, cond, {})))
keys = cm.mf.candidates(whole, cond, {}, unit)
brief = _market_brief(whole.get(cm.mf.pick(whole, cond, {}, unit)))
except (cm.mf.FormulaError, KeyError, TypeError):
return None
return {**brief, "조건": cond, "후보": len(keys)}
@@ -367,7 +368,7 @@ def _prices(whole, row: dict) -> dict:
out = {}
for item in row.get("호표") or []:
if isinstance(item.get("요소"), dict):
out[cm.mf.cond_text(item["요소"])] = _pick_brief(whole, item["요소"])
out[cm.mf.cond_text(item["요소"])] = _pick_brief(whole, item["요소"], item.get("단위"))
continue
ref = str(item.get("요소", ""))
if item.get("종류") != "로직" and "{" not in ref:
@@ -450,14 +451,15 @@ def _market_brief(row: dict) -> dict:
}
def materials(sub: str, detail: str, spec: str, region: str, limit: int) -> dict:
def materials(sub: str, detail: str, spec: str, region: str, unit: str, limit: int) -> dict:
"""재료 고르기 조건 안 후보 목록 — 화면·테스트 컨테이너가 같이 씀.
`unit` = 호표 줄 단위 — 주면 그 단위 줄만(단위가 다르면 다른 물건).
`기본` = 시험 계산이 쓸 줄(대표 줄이 없을 때의 첫 줄) · 그 줄을 `items` 맨 앞에 둠."""
whole = cm.master(folder=FOLDER)
cond = {"구분": sub, "상세구분": detail or None, "규격": spec or None}
env = {cm.mf.REGION: region} if region else {}
keys = cm.mf.candidates(whole, cond, env)
first = cm.mf.pick(whole, cond, env) if keys else None
keys = cm.mf.candidates(whole, cond, env, unit or None)
first = cm.mf.pick(whole, cond, env, unit or None) if keys else None
keys = [first] + [k for k in keys if k != first] if first else keys
return {
"total": len(keys),