feat: v1.5.0 - F009+F010 MAP→List使用BallList模板,List→MAP使用BallMAP模板

This commit is contained in:
2026-06-06 12:17:06 +08:00
parent 3f53d6746c
commit 351f56ecb5

View File

@@ -33,23 +33,44 @@ def wait_for_exit():
# ── Path helpers ────────────────────────────────────────────────────
def _find_template_path() -> str | None:
"""查找根目录下的 PinMAP-Template.xlsx。
def _find_balllist_template_path() -> str | None:
"""查找根目录下的 BallList-Template.xlsx。
MAP→List 输出使用 BallList 模板(而非旧 PinMAP 模板)。
搜索顺序:
1. 与 run.bat 同级的根目录
2. 当前工作目录
"""
# 从 Code/src 回退到根目录
src_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(os.path.dirname(src_dir)) # pinmap-to-pinlist/
template_path = os.path.join(root_dir, "PinMAP-Template.xlsx")
template_path = os.path.join(root_dir, "BallList-Template.xlsx")
if os.path.exists(template_path):
return template_path
# 回退到当前工作目录
cwd_template = os.path.join(os.getcwd(), "PinMAP-Template.xlsx")
cwd_template = os.path.join(os.getcwd(), "BallList-Template.xlsx")
if os.path.exists(cwd_template):
return cwd_template
return None
def _find_ballmap_template_path() -> str | None:
"""查找根目录下的 BallMAP-Template.xlsx。
List→MAP 输出使用 BallMAP 模板(而非旧 PinMAP 模板)。
搜索顺序:
1. 与 run.bat 同级的根目录
2. 当前工作目录
"""
src_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(os.path.dirname(src_dir)) # pinmap-to-pinlist/
template_path = os.path.join(root_dir, "BallMAP-Template.xlsx")
if os.path.exists(template_path):
return template_path
cwd_template = os.path.join(os.getcwd(), "BallMAP-Template.xlsx")
if os.path.exists(cwd_template):
return cwd_template
@@ -150,17 +171,17 @@ def run_map_to_list(filepath: str):
data[f'A{row}'] = pin_name
data[f'B{row}'] = str(pin_num)
# 尝试读取模板样式F007
template_path = _find_template_path()
# 尝试读取 BallList 模板样式F009
template_path = _find_balllist_template_path()
template_style = None
if template_path:
template_style = read_template_styles(template_path)
if template_style:
print(f"[INFO] 已加载模板样式: {template_path}")
print(f"[INFO] 已加载 BallList 模板样式: {template_path}")
else:
print("[WARN] 模板文件存在但解析失败,使用默认样式")
print("[WARN] BallList 模板文件存在但解析失败,使用默认样式")
else:
print("[INFO] 未检测到模板文件,使用默认样式")
print("[INFO] 未检测到 BallList-Template.xlsx,使用默认样式")
if template_style is not None:
write_xlsx_with_style(data, output_path, template_style)
@@ -260,17 +281,17 @@ def run_list_to_map(filepath: str):
print(f"[INFO] 正在生成 PinMAP 并写入: {output_path}")
try:
# 尝试读取模板样式F007 — 从根目录读取而非输入文件路径
template_path = _find_template_path()
# 尝试读取 BallMAP 模板样式F010
template_path = _find_ballmap_template_path()
template_style = None
if template_path:
template_style = read_template_styles(template_path)
if template_style:
print(f"[INFO] 已加载模板样式: {template_path}")
print(f"[INFO] 已加载 BallMAP 模板样式: {template_path}")
else:
print("[WARN] 模板文件存在但解析失败,使用默认样式")
print("[WARN] BallMAP 模板文件存在但解析失败,使用默认样式")
else:
print("[INFO] 未检测到模板文件,使用默认样式")
print("[INFO] 未检测到 BallMAP-Template.xlsx,使用默认样式")
generate_pinmap(
entries=entries,