v1.1.0: 增加交互提示、路径输入、窗口属性配置
- main.py: 增加show_banner()启动说明、各阶段[INFO]日志、结果摘要、任意键退出 - file_selector.py: 重写为路径输入→验证→空输入弹窗回退→不存在循环重试 - run.bat: 新建启动脚本(chcp 65001, mode con cols=80 lines=20, color 0B, title固定署名, pause) - Code/docs/modification-assessment.md: 修改需求评估文档
This commit is contained in:
60
Releases/v1.0.1/source/models.py
Normal file
60
Releases/v1.0.1/source/models.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""Data models for PinMAP → PinList conversion."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
|
||||
@dataclass
|
||||
class Pin:
|
||||
"""A single pin on the package."""
|
||||
number: int
|
||||
name: str
|
||||
edge: str # "top" | "right" | "bottom" | "left"
|
||||
position_on_edge: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class PinMAP:
|
||||
"""Parsed pin map from an Excel file."""
|
||||
package_info: str
|
||||
pins: list[Pin]
|
||||
width: int
|
||||
height: int
|
||||
grid_origin: tuple[int, int] # (row, col) of top-left corner
|
||||
raw_cells: dict[tuple[int, int], str] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PinList:
|
||||
"""Flat pin list for output."""
|
||||
package_info: str
|
||||
rows: list[tuple[str, int]] # [(PinName, Pin序号), ...]
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValidationError:
|
||||
"""A single validation issue."""
|
||||
level: str # "error" | "warning"
|
||||
message: str
|
||||
details: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ValidationResult:
|
||||
"""Aggregate validation result."""
|
||||
is_valid: bool
|
||||
errors: list[ValidationError] = field(default_factory=list)
|
||||
warnings: list[ValidationError] = field(default_factory=list)
|
||||
|
||||
|
||||
# ── Custom exceptions ──────────────────────────────────────────────
|
||||
|
||||
class PinMapError(Exception):
|
||||
"""Base exception for this project."""
|
||||
|
||||
|
||||
class FileFormatError(PinMapError):
|
||||
"""Raised when a file is not a valid Excel format."""
|
||||
|
||||
|
||||
class StructureError(PinMapError):
|
||||
"""Raised when the PinMAP structure is invalid or unrecognisable."""
|
||||
Reference in New Issue
Block a user