模板导出增强 + 模特性别分组 + 三合一提示词精简
1) 模板导出:识别「基码表-胸围」填 sku.bust(多个胸围列都填);申报价格模糊匹配多列统一按加价后价格填写;详情图文不再拼接 img_url_2;SPU 款式来源统一填「现货款」;商品产地国家简称映射(沙特→沙特阿拉伯) 2) 模特性别分组:model_features 按男女分组,按模板类目含男/女固定取对应性别模特(含 Pinterest 模式 pipeline) 3) 三合一提示词:去掉 DESIGN CONTENT 四要素描述(设计已由设计稿提供) 4) 生图尺寸:全部改为读 config 不再硬编码(设计图 compose.design_size / 合成图 compose.size / 种草图 seed_shot.size)
This commit is contained in:
@@ -81,6 +81,7 @@ SPU_CODE_COL = 2 # B 列:SPU货号
|
||||
VALID_LEVELS = ("spu", "sku", "单sku商品")
|
||||
|
||||
_GROUP_BRACKET = re.compile(r"([^)]*)|\([^)]*\)") # 去掉分组名里的括号说明
|
||||
_UNIT_SUFFIX = re.compile(r"[((](?:cm|g|kg|mm|m²|m2)[))]\s*$", re.IGNORECASE) # 列名尾部单位(肩宽(cm)→肩宽)
|
||||
|
||||
|
||||
class TemplateRouter:
|
||||
@@ -333,7 +334,11 @@ class TemplateRouter:
|
||||
# 数据插入
|
||||
# ------------------------------------------------------------------
|
||||
def resolve_col(self, key: str | int) -> int:
|
||||
"""把键解析为列号:完整表头 / 列名 / 列号 / Excel 列字母。"""
|
||||
"""把键解析为列号:完整表头 / 列名 / 列号 / Excel 列字母。
|
||||
|
||||
精确匹配失败时做单位归一化匹配(去掉尾部(cm)/(g)…),
|
||||
兼容「肩宽(cm)」↔「肩宽」这类带单位/不带单位的列名差异。
|
||||
"""
|
||||
if isinstance(key, int):
|
||||
return key
|
||||
key_s = str(key).strip()
|
||||
@@ -343,6 +348,15 @@ class TemplateRouter:
|
||||
return self.column_map[key_s]
|
||||
if re.fullmatch(r"[A-Za-z]{1,3}", key_s):
|
||||
return column_index_from_string(key_s.upper())
|
||||
norm = _UNIT_SUFFIX.sub("", key_s).strip()
|
||||
if norm and norm != key_s:
|
||||
if norm in self.column_map:
|
||||
return self.column_map[norm]
|
||||
if norm in self.header_map:
|
||||
return self.header_map[norm]
|
||||
for name, col in self.column_map.items():
|
||||
if _UNIT_SUFFIX.sub("", str(name)).strip() == norm:
|
||||
return col
|
||||
raise KeyError(f"无法识别的表头: {key!r}(可用完整表头/列名/列号/列字母)")
|
||||
|
||||
def _value_by_col(self, data: dict, name: str):
|
||||
|
||||
Reference in New Issue
Block a user