Files
Aislo/resources/tester/scratch/inspect_new_const_tables.py
T

48 lines
1.6 KiB
Python

import json
import sys
from pathlib import Path
sys.stdout.reconfigure(encoding='utf-8')
const_master_path = Path('resources/data_work_item_master/const_work_item_master_2026-01-01.json')
with open(const_master_path, 'r', encoding='utf-8') as f:
const_master = json.load(f)
const_pum_path = Path('resources/data_cost_input_value/pum_const_2026.json')
with open(const_pum_path, 'r', encoding='utf-8') as f:
const_pum = json.load(f)
pum_tables = {t['table_id']: t for t in const_pum.get('variables', {}).get('pum', {}).get('tables', [])}
target_c_ids = [f"C{i}" for i in range(2193, 2203)]
print(f"Target new tables: {target_c_ids}\n")
# Find in work_items
found_tables = {}
for wi in const_master['work_items']:
for t in wi.get('tables', []):
tid = t.get('pum_table_id')
if tid in target_c_ids:
found_tables[tid] = (wi, t)
for tid in target_c_ids:
pt = pum_tables.get(tid)
pair = found_tables.get(tid)
print(f"==================== [{tid}] ====================")
if pt:
print(f"pum_const: line {pt.get('line')} | sec: {pt.get('section')}")
print(f" headers: {pt.get('headers')}")
print(f" rows count: {len(pt.get('rows', []))}")
if pt.get('rows'):
print(f" sample row: {pt['rows'][0]}")
else:
print(f"pum_const: NOT FOUND")
if pair:
wi, mt = pair
print(f"master WI: {wi.get('work_item_code')} - {wi.get('name')}")
print(f" master section: {mt.get('section')} | form: {mt.get('pum_form')} | basis: {mt.get('basis_quantity')} {mt.get('basis_unit')}")
else:
print(f"master: NOT FOUND in work_items")
print()