Stage 4.1: remove remaining Japanese delivery field keys

This commit is contained in:
OpenAI Codex
2026-03-24 10:17:19 +08:00
parent 5089746b07
commit 94c8f45468
2 changed files with 77 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import json
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import pymysql
@@ -90,6 +91,46 @@ def evaluate_match_expr(match_expr: dict[str, Any], context: dict[str, Any]) ->
return True
def load_local_field_name_rules() -> dict[str, FieldNameRule]:
mapping_path = Path(__file__).resolve().parent / "tasks" / "pbf" / "mappings" / "navsea_field_name_rules_v1.yaml"
if not mapping_path.exists():
return {}
rules: dict[str, FieldNameRule] = {}
current: dict[str, str] = {}
for raw_line in mapping_path.read_text(encoding="utf-8").splitlines():
line = raw_line.strip()
if not line or line.startswith("#") or line in {"ruleset: navsea_field_name_rules_v1", "rules:"}:
continue
if line.startswith("- field_name_jp:"):
if current.get("field_name_jp") and current.get("field_name_std"):
rules[current["field_name_jp"]] = FieldNameRule(
field_name_jp=current["field_name_jp"],
field_name_std=current["field_name_std"],
field_group_name=current.get("field_group", ""),
keep_in_delivery=current.get("keep_in_delivery", "true").lower() == "true",
keep_in_engineering=current.get("keep_in_engineering", "true").lower() == "true",
normalization_class=current.get("normalization_class", ""),
)
current = {"field_name_jp": line.split(":", 1)[1].strip()}
continue
if not current or ":" not in line:
continue
key, value = line.split(":", 1)
current[key.strip()] = value.strip()
if current.get("field_name_jp") and current.get("field_name_std"):
rules[current["field_name_jp"]] = FieldNameRule(
field_name_jp=current["field_name_jp"],
field_name_std=current["field_name_std"],
field_group_name=current.get("field_group", ""),
keep_in_delivery=current.get("keep_in_delivery", "true").lower() == "true",
keep_in_engineering=current.get("keep_in_engineering", "true").lower() == "true",
normalization_class=current.get("normalization_class", ""),
)
return rules
class NavSeaMappingRegistry:
def __init__(
self,
@@ -182,6 +223,7 @@ class NavSeaMappingRegistry:
)
for row in cur.fetchall()
}
field_name_rules.update(load_local_field_name_rules())
cur.execute(
"""