DB_JOB/작업파일/완료/광역_사이트맵/전북특별자치도/13.정읍시/_decide.py
hehihoho3 df16c98366 백업: DB수집 전체 스냅샷 (공공기관2 정리 전)
공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 18:15:40 +09:00

56 lines
2.1 KiB
Python

"""Build the decision lists from _dump.json + _report.json and write a decoded review file."""
import json, io, re
data = json.load(io.open('_dump.json', encoding='utf-8'))
rep = json.load(io.open('_report.json', encoding='utf-8'))
cnt = {p['r']: p['count'] for p in rep['pages']}
err = {p['r']: p['err'] for p in rep['pages']}
navblank = rep['navblank']
byr = {row['r']: row for row in data}
def code_of(row):
mc = re.search(r'menuCd=(DOM_\d+)', row.get('K', ''))
return mc.group(1) if mc else None
def lbl(row):
return row.get('G') or row.get('F') or row.get('E') or row.get('D') or ''
fill_M = [] # real boards: set M=count
reclass = [] # 게시판 -> 페이지
to_site = [] # nav target_blank & not 사이트 (task 2)
for row in data:
r = row['r']; L = row.get('L'); code = code_of(row)
c = cnt.get(r)
# task 2: nav target=_blank => site
if code and navblank.get(code) and L not in ('사이트', None):
to_site.append((r, L, lbl(row)))
if L == '게시판':
if c is not None:
fill_M.append((r, row.get('M'), c, lbl(row)))
else:
reclass.append((r, row.get('M'), row.get('P'), row.get('Q'), err.get(r), lbl(row)))
out = io.open('_decision.txt', 'w', encoding='utf-8')
def w(s=''): out.write(s + '\n')
w('========== TASK 2: nav target=_blank but NOT 사이트 (would reclass to 사이트) ==========')
w('count=%d' % len(to_site))
for r, L, name in to_site:
w(' r%-4d L=%-4s %s' % (r, L, name))
w('')
w('========== TASK 1: real boards (have bbs_total) -> set M=count ==========')
w('count=%d' % len(fill_M))
for r, oldM, c, name in fill_M:
flag = '' if oldM in (0, None) else ' <<old M=%s' % oldM
w(' r%-4d M:%s->%-7d %s%s' % (r, str(oldM), c, name, flag))
w('')
w('========== TASK 3: 게시판 WITHOUT bbs_total -> 페이지 (M->1) ==========')
w('count=%d' % len(reclass))
for r, oldM, P, Q, e, name in reclass:
w(' r%-4d (M=%s P=%s Q=%s err=%s) %s' % (r, oldM, P, Q, e, name))
out.close()
print('to_site=%d fill_M=%d reclass=%d' % (len(to_site), len(fill_M), len(reclass)))