82 lines
1.9 KiB
Python
82 lines
1.9 KiB
Python
|
|
# @line_count 100
|
|||
|
|
"""JSON解析器适配器基类"""
|
|||
|
|
from abc import ABC, abstractmethod
|
|||
|
|
from typing import List, Dict, Any
|
|||
|
|
|
|||
|
|
|
|||
|
|
class BaseParserAdapter(ABC):
|
|||
|
|
"""解析器适配器抽象基类"""
|
|||
|
|
|
|||
|
|
def __init__(self, data: Dict[str, Any]):
|
|||
|
|
"""
|
|||
|
|
初始化适配器
|
|||
|
|
|
|||
|
|
Args:
|
|||
|
|
data: 解析后的JSON数据
|
|||
|
|
"""
|
|||
|
|
self.data = data
|
|||
|
|
|
|||
|
|
@abstractmethod
|
|||
|
|
def extract_function_points(self) -> List[Dict[str, Any]]:
|
|||
|
|
"""
|
|||
|
|
提取功能点列表
|
|||
|
|
|
|||
|
|
Returns:
|
|||
|
|
功能点列表,统一格式:
|
|||
|
|
- module_name: 所属模块
|
|||
|
|
- function_name: 功能名称
|
|||
|
|
- description: 功能描述
|
|||
|
|
- operation_steps: 操作步骤(可选)
|
|||
|
|
- requirement_id: 需求编号(可选)
|
|||
|
|
- requirement_type: 需求类型(可选)
|
|||
|
|
"""
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
@abstractmethod
|
|||
|
|
def get_document_info(self) -> Dict[str, Any]:
|
|||
|
|
"""
|
|||
|
|
获取文档基本信息
|
|||
|
|
|
|||
|
|
Returns:
|
|||
|
|
文档信息字典,统一格式:
|
|||
|
|
- title: 文档标题
|
|||
|
|
- version: 版本(可选)
|
|||
|
|
- date: 日期(可选)
|
|||
|
|
- section_count: 章节数量
|
|||
|
|
"""
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
@abstractmethod
|
|||
|
|
def get_sections(self) -> List[Dict[str, Any]]:
|
|||
|
|
"""
|
|||
|
|
获取所有章节信息
|
|||
|
|
|
|||
|
|
Returns:
|
|||
|
|
章节列表
|
|||
|
|
"""
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
@abstractmethod
|
|||
|
|
def get_module_summary(self) -> List[Dict[str, Any]]:
|
|||
|
|
"""
|
|||
|
|
获取模块摘要
|
|||
|
|
|
|||
|
|
Returns:
|
|||
|
|
模块摘要列表
|
|||
|
|
"""
|
|||
|
|
pass
|
|||
|
|
|
|||
|
|
@staticmethod
|
|||
|
|
@abstractmethod
|
|||
|
|
def can_parse(data: Dict[str, Any]) -> bool:
|
|||
|
|
"""
|
|||
|
|
检测是否能解析该格式
|
|||
|
|
|
|||
|
|
Args:
|
|||
|
|
data: JSON数据
|
|||
|
|
|
|||
|
|
Returns:
|
|||
|
|
是否能解析
|
|||
|
|
"""
|
|||
|
|
pass
|