refactor: 预留并行修复所需的共享接口

This commit is contained in:
2026-10-25 06:48:26 +08:00
parent d96f430a7d
commit 6b84a5e406
10 changed files with 179 additions and 42 deletions
+2 -13
View File
@@ -6,6 +6,8 @@ import csv
import io
from pathlib import Path
from app.shared.ids import normalize_id
_HEADER_KEYS = {
"栅格id",
"20米栅格id",
@@ -19,19 +21,6 @@ _HEADER_KEYS = {
}
def normalize_id(value) -> str:
if value is None:
return ""
text = str(value).strip().strip("\ufeff")
text = text.translate(str.maketrans("0123456789", "0123456789"))
text = "".join(text.split())
if text.endswith(".0") and text[:-2].isdigit():
text = text[:-2]
if not text or not text.isdigit():
return ""
return text
def _header_index(header: list[str]) -> int | None:
for index, name in enumerate(header):
key = name.strip().lower().replace(" ", "").replace("_", "")