feat: поддержка .gge, .esw, .xml в пакетном обработчике
Файлы сметных программ (ГРАНД-Смета .gge/.esw) — это XML. Теперь extract_zip, batch_v2, batch_v3 находят и обрабатывают все сметные форматы: .xlsx, .xls, .gge, .esw, .xml GGE/ESW копируются как XML без xlsx-конвертации. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+25
-4
@@ -78,10 +78,23 @@ def convert_all_to_csv(source_dir: str, csv_dir: str) -> dict:
|
||||
all_csv = []
|
||||
total_bytes = 0
|
||||
|
||||
xlsx_files = sorted(Path(source_dir).rglob("*.xlsx"))
|
||||
xlsx_files = [f for f in xlsx_files if not f.name.startswith("~$")]
|
||||
SMETA_EXT = {'.xlsx', '.xls', '.gge', '.esw', '.xml'}
|
||||
xlsx_files = sorted(
|
||||
f for f in Path(source_dir).rglob("*")
|
||||
if f.is_file() and f.suffix.lower() in SMETA_EXT
|
||||
and not f.name.startswith("~$") and not f.name.startswith("._")
|
||||
)
|
||||
|
||||
for xlsx in xlsx_files:
|
||||
# .gge/.esw are XML — copy as-is (no xlsx conversion needed)
|
||||
if xlsx.suffix.lower() in ('.gge', '.esw', '.xml'):
|
||||
dst = Path(csv_dir) / f"{xlsx.stem}.xml"
|
||||
import shutil
|
||||
shutil.copy2(str(xlsx), str(dst))
|
||||
size = dst.stat().st_size
|
||||
all_csv.append({"path": str(dst), "name": dst.name, "bytes": size})
|
||||
total_bytes += size
|
||||
continue
|
||||
csvs = convert_xlsx_to_csv(str(xlsx), csv_dir)
|
||||
for c in csvs:
|
||||
size = Path(c).stat().st_size
|
||||
@@ -102,8 +115,11 @@ def select_samples(source_dir: str, csv_info: dict) -> list[str]:
|
||||
Strategy: pick files of different sizes and from different subdirs.
|
||||
Returns list of xlsx file paths (originals, not CSV).
|
||||
"""
|
||||
SMETA_EXT = {'.xlsx', '.xls', '.gge', '.esw', '.xml'}
|
||||
xlsx_files = sorted(
|
||||
[f for f in Path(source_dir).rglob("*.xlsx") if not f.name.startswith("~$")],
|
||||
[f for f in Path(source_dir).rglob("*")
|
||||
if f.is_file() and f.suffix.lower() in SMETA_EXT
|
||||
and not f.name.startswith("~$") and not f.name.startswith("._")],
|
||||
key=lambda f: f.stat().st_size,
|
||||
)
|
||||
if len(xlsx_files) <= MAX_SAMPLE_FILES:
|
||||
@@ -387,7 +403,12 @@ def run_batch_v2(job_id: str, script: str, source_dir: str, target_file: str):
|
||||
job["status"] = "running"
|
||||
job["started_at"] = time.time()
|
||||
|
||||
source_files = [str(f) for f in Path(source_dir).rglob("*.xlsx") if not f.name.startswith("~$")]
|
||||
SMETA_EXT = {'.xlsx', '.xls', '.gge', '.esw', '.xml'}
|
||||
source_files = [
|
||||
str(f) for f in Path(source_dir).rglob("*")
|
||||
if f.is_file() and f.suffix.lower() in SMETA_EXT
|
||||
and not f.name.startswith("~$") and not f.name.startswith("._")
|
||||
]
|
||||
job["total_files"] = len(source_files)
|
||||
job["processed"] = 0
|
||||
job["errors"] = []
|
||||
|
||||
Reference in New Issue
Block a user