feat: парсер .arp/.arps (АРПС 1.10, Smeta.RU) + MCP-tool + GLM-путь
Пункт 6 мастер-плана: .arp/.arps (294 файла) не читались. АРПС 1.10 — текстовый формат (cp866, поля через '#'): тип 3=шапка (шифр/название/итог), тип 20=позиция (обоснование= шифр, ед., наимен., стоимость). gge_tools.parse_arp_file + MCP-tool parse_arp_file + .arp/.arps в ALLOWED обоих bridge + инлайн-чтение в GLM-пути. Объём-поле в АРПС неоднозначно — по /sanity не выдумываю, беру надёжное (код/ед./наимен./итог). Юнит mutation-safe + серверный real-тест на настоящем .arp (шифр 00-02-7-00-01Р, 70 позиций, итог 6.1М). APP_VERSION→2026-07-15f. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -249,6 +249,53 @@ def parse_gsfx_file(path: Path) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def parse_arp_file(path: Path) -> dict:
|
||||
"""Разобрать .arp/.arps (АРПС 1.10 — открытый текстовый формат обмена смет,
|
||||
Smeta.RU / ПК АВС). Кодировка cp866, поля через '#', первое поле = тип записи.
|
||||
|
||||
Тип 3 — шапка сметы: [4]=шифр, [5]=название, [14]=итог.
|
||||
Тип 20 — позиция: [2]=обоснование (первый токен = шифр расценки), [3]=ед.изм,
|
||||
[4]=наименование, [15]=стоимость позиции. Объём НЕ извлекаем — его поле в АРПС
|
||||
неоднозначно, лучше не давать выдуманное число.
|
||||
"""
|
||||
try:
|
||||
raw = Path(path).read_bytes()
|
||||
except OSError as e:
|
||||
return {'error': f'{type(e).__name__}: {e}', 'path': str(path)}
|
||||
text = raw.decode('cp866', 'replace')
|
||||
code = name = ''
|
||||
total = 0.0
|
||||
positions: list[dict] = []
|
||||
for line in text.splitlines():
|
||||
if not line or '#' not in line:
|
||||
continue
|
||||
f = line.split('#')
|
||||
rec = f[0]
|
||||
if rec == '3' and len(f) > 5:
|
||||
code = f[4].strip()
|
||||
name = f[5].strip()
|
||||
if len(f) > 14:
|
||||
total = _ru_float(f[14])
|
||||
elif rec == '20' and len(f) > 4:
|
||||
just = f[2].strip()
|
||||
pcode = just.split(' ')[0] if just else ''
|
||||
unit = f[3].strip()
|
||||
pname = f[4].strip()
|
||||
ptotal = _ru_float(f[15]) if len(f) > 15 else 0.0
|
||||
if pname or pcode:
|
||||
positions.append({'code': pcode, 'name': pname,
|
||||
'unit': unit, 'total': ptotal})
|
||||
return {
|
||||
'path': str(path),
|
||||
'format': 'arp',
|
||||
'code': code,
|
||||
'name': name,
|
||||
'total': total,
|
||||
'positions_count': len(positions),
|
||||
'positions': positions,
|
||||
}
|
||||
|
||||
|
||||
def index_gge_directory(dir_path: Path, save_index_to: Path | None = None) -> dict:
|
||||
"""Пройти все .gge в dir_path рекурсивно, распарсить.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user