Refactor discrete material cleaner to improve maintainability and testability: - Introduce dependency injection pattern for service components - Add interfaces (IPageNavigator, IMaterialExtractor, IDeletionChecker) - Extract PageNavigator service for page navigation logic - Extract MaterialExtractor service for data extraction - Extract DatabaseDeletionChecker service for deletion logic - Add MaterialInfo data model for structured data - Centralize configuration (CleanerConfig, UIConstants) - Implement separation of concerns across services layer Also includes comprehensive execution mechanism documentation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
"""
|
|
物料信息提取接口
|
|
定义从页面提取物料信息的抽象接口
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from playwright.sync_api import Frame
|
|
from typing import List
|
|
from models.material_info import MaterialInfo
|
|
|
|
|
|
class IMaterialExtractor(ABC):
|
|
"""物料信息提取接口"""
|
|
|
|
@abstractmethod
|
|
def extract_detail_count(self, frame: Frame) -> int:
|
|
"""
|
|
提取详细信息数量
|
|
|
|
Args:
|
|
frame: 目标 iframe
|
|
|
|
Returns:
|
|
详细信息数量
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def extract_detail_status(self, frame: Frame) -> str:
|
|
"""
|
|
提取备料状态
|
|
|
|
Args:
|
|
frame: 目标 iframe
|
|
|
|
Returns:
|
|
备料状态文本
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def extract_materials(self, frame: Frame, count: int) -> List[MaterialInfo]:
|
|
"""
|
|
提取所有物料信息
|
|
|
|
Args:
|
|
frame: 目标 iframe
|
|
count: 物料数量
|
|
|
|
Returns:
|
|
物料信息列表
|
|
"""
|
|
pass
|