feat(ТСН): сборка tsn_ref.sqlite и доступ к базе (T5, T6)
build_tsn_ref собирает базу из выжимок: release, sources, works, work_resources, index_releases/values, quarantine. Дубли шифра с другой ценой — провал сборки; apply проверяет staging, отказывается при падении числа работ больше чем на 30%, делает бэкап и подменяет файл атомарно. tsn_ref читает базу только на чтение и возвращает статус вместо пустоты: db_unavailable, db_corrupt, schema_mismatch, not_found. Поиск по коду и по словам названия; коэффициенты по шифру и выпуску; строка покрытия для промпта. В разборе появились имена расценок из подписи таблицы (продолжение не затирает). 9 проверок; мутации (снять проверку дублей, убрать бэкап) ловятся. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,7 @@ def parse_rate_book(path: str, meta: dict | None = None) -> dict:
|
||||
current_cols: list[tuple[str, float]] | None = None
|
||||
current_unit = ""
|
||||
current_table = ""
|
||||
current_caption = ""
|
||||
resource_rows: dict[str, dict] = defaultdict(dict)
|
||||
pages_total = 0
|
||||
headers_seen = 0
|
||||
@@ -147,6 +148,13 @@ def parse_rate_book(path: str, meta: dict | None = None) -> dict:
|
||||
headers_seen += len(CAPTION_RE.findall(text))
|
||||
headers.update(_table_headers(text))
|
||||
# «Таблица 1-5» держится до следующей таблицы: шапка может быть на прошлой странице
|
||||
for line in text.splitlines():
|
||||
m = CAPTION_RE.match(line)
|
||||
if m:
|
||||
current_table = m.group(1)
|
||||
# «(продолжение)» — та же таблица; имя берём с первой подписи
|
||||
if "продолжение" not in line.lower():
|
||||
current_caption = " ".join(line.split())
|
||||
found = CAPTION_RE.findall(text)
|
||||
if found:
|
||||
current_table = found[-1]
|
||||
@@ -171,6 +179,7 @@ def parse_rate_book(path: str, meta: dict | None = None) -> dict:
|
||||
w = works.setdefault(code, {
|
||||
"code": code, "table_no": current_table, "page": pno + 1,
|
||||
"unit": current_unit, "resources": [],
|
||||
"name": current_caption or f"Таблица {current_table}",
|
||||
})
|
||||
w["pz"] = val
|
||||
parsed_tables.add(current_table)
|
||||
|
||||
Reference in New Issue
Block a user