Improve LLM and CSV processing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Repinoid
2026-10-23 10:09:34 +03:00
co-authored by Copilot
parent aa1d15509b
commit 49171c93f9
14 changed files with 315 additions and 92 deletions
+25
View File
@@ -0,0 +1,25 @@
"""Helpers for assigning stable, collision-free output filenames."""
import os
from typing import Dict, Optional
def resolve_name(name: str, content: bytes, seen: Dict[str, bytes]) -> Optional[str]:
"""Return a unique name, or None when the same name and content were seen.
Name collisions with different content receive numeric suffixes before
the extension, while exact duplicates are omitted.
"""
if name not in seen:
seen[name] = content
return name
if seen[name] == content:
return None
base, ext = os.path.splitext(name)
index = 2
while f"{base}_{index}{ext}" in seen:
index += 1
resolved = f"{base}_{index}{ext}"
seen[resolved] = content
return resolved