feat(855-E L1): 수식 문서 이름표 싣기 — 빌더 · M01 저장 길이 로직 줄과 두 곳에 같게 씀
- master_doc.TAGS(원문번호 · 구분 · 상세구분 · 소유 · 비고 · 개정 · 별칭) · FILE_TAGS(원문 · 부문 · 차례) · tag() · tags_of() — 셈 · 지문(doc_fp) 밖 · `키` 바로 뒤 - 빌더 files_of = 문서 줄 머리 이름표 · 파일 머리 이름표를 로직 줄 · 로직 파일 머리에서(손고침 · 기계덮음 문서도) · --check 새 기준 - M01 Doc: of_row(빌더와 같은 꼴) · save 가 이름표를 로직 줄 것으로 실음(화면 왕복에 안 지워짐 · 손고침 판정 그대로) · sync_tags - Store_Make.save 뒤 고친 · 더한 로직 줄 이름표를 문서에도(비고 · 별칭 · 자체 이름 · 개정 확인 · 신규 · 별칭 모아 보기 · 기계 등록 — 모두 이 길) - build_로직_개정 이 문서 줄 머리 「개정」 도 씀 - _수식문서_틀.md 이름표 두 줄 · 새 시험 test_855_l1_tags(1,521 이름표 = 로직 줄 · 파일 머리 같음 · 비고 · 별칭 넣고 뺌 · 문서 저장 왕복 · 복사 · 자체 비고 · 삭제 뒤도 같음 · doc_fp 같음) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,37 @@ def _file_for(key: str) -> str:
|
||||
return OWN_FILE
|
||||
|
||||
|
||||
def _row(key: str) -> dict | None:
|
||||
"""그 키의 로직 줄(기억 · 읽기만) — 없음 = None."""
|
||||
for data in store.loaded()[0].values():
|
||||
if data.get("그룹") == "로직":
|
||||
for row in data.get("줄") or []:
|
||||
if str(row.get("키")) == key:
|
||||
return row
|
||||
return None
|
||||
|
||||
|
||||
def sync_tags(keys) -> int:
|
||||
"""로직 줄 이름표를 수식 문서 줄 머리에 같게(855 L1 · 읽는 쪽이 문서로 옮길 때까지 두 곳) —
|
||||
로직 줄 · 문서가 둘 다 있는 키만 · 바뀐 문서 파일만 씀(`put`) · 바꾼 문서 수."""
|
||||
want = {k: r for k in set(map(str, keys)) if (r := _row(k)) is not None}
|
||||
if not want:
|
||||
return 0
|
||||
n = 0
|
||||
with _LOCK:
|
||||
for path in sorted(folder().glob("수식_*.json")):
|
||||
data, hit = ml.load_file(path), False
|
||||
rows = data.get("줄") or []
|
||||
for at, doc in enumerate(rows):
|
||||
row = want.get(str(doc.get("키")))
|
||||
if row is not None and md.tags_of(doc) != md.tags_of(row):
|
||||
rows[at], hit = md.tag(doc, row), True
|
||||
n += 1
|
||||
if hit:
|
||||
put(path, data)
|
||||
return n
|
||||
|
||||
|
||||
def built(key: str) -> dict | None:
|
||||
"""빌더가 지을 그 키 문서(옛 로직 줄 변환 · `build_수식문서_802_2`) · 로직 줄 없음 · 변환 틀림 = None."""
|
||||
for data in store.loaded()[0].values():
|
||||
@@ -154,9 +185,10 @@ def of_row(row: dict) -> dict | None:
|
||||
import master_doc_convert as cv
|
||||
|
||||
try:
|
||||
return cv.convert(store.loaded()[1], row)[0]
|
||||
doc = cv.convert(store.loaded()[1], row)[0]
|
||||
except Exception: # noqa: BLE001 — 변환 틀림 = 빌더 문서 없음(표지 안 담)
|
||||
return None
|
||||
return md.tag(doc, row) # 855 L1 이름표 = 빌더와 같게
|
||||
|
||||
|
||||
def make(key: str) -> bool:
|
||||
@@ -226,6 +258,8 @@ def save(doc: dict, 판: str | None = None) -> dict:
|
||||
doc = _check(doc)
|
||||
key = str(doc["키"]).strip()
|
||||
with _LOCK:
|
||||
if (row := _row(key)) is not None: # 이름표 = 로직 줄 것(화면 왕복에 안 지워짐 · 855 L1)
|
||||
doc = md.tag(doc, row)
|
||||
doc = layered(doc, key)
|
||||
name = _file_for(key)
|
||||
path = folder() / name
|
||||
|
||||
Reference in New Issue
Block a user