fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题
- 添加类型注解
This commit is contained in:
OpenClaw Bot
2026-02-27 18:09:24 +08:00
parent 646b64daf7
commit 17bda3dbce
38 changed files with 1993 additions and 1972 deletions

View File

@@ -3,12 +3,12 @@ InsightFlow Export Module - Phase 5
支持导出知识图谱、项目报告、实体数据和转录文本
"""
import base64
import io
import json
import base64
from datetime import datetime
from typing import List, Dict, Any
from dataclasses import dataclass
from datetime import datetime
from typing import Any
try:
import pandas as pd
@@ -20,9 +20,16 @@ except ImportError:
try:
from reportlab.lib import colors
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
from reportlab.platypus import (
PageBreak,
Paragraph,
SimpleDocTemplate,
Spacer,
Table,
TableStyle,
)
REPORTLAB_AVAILABLE = True
except ImportError:
@@ -35,9 +42,9 @@ class ExportEntity:
name: str
type: str
definition: str
aliases: List[str]
aliases: list[str]
mention_count: int
attributes: Dict[str, Any]
attributes: dict[str, Any]
@dataclass
@@ -56,8 +63,8 @@ class ExportTranscript:
name: str
type: str # audio/document
content: str
segments: List[Dict]
entity_mentions: List[Dict]
segments: list[dict]
entity_mentions: list[dict]
class ExportManager:
@@ -67,7 +74,7 @@ class ExportManager:
self.db = db_manager
def export_knowledge_graph_svg(
self, project_id: str, entities: List[ExportEntity], relations: List[ExportRelation]
self, project_id: str, entities: list[ExportEntity], relations: list[ExportRelation]
) -> str:
"""
导出知识图谱为 SVG 格式
@@ -207,7 +214,7 @@ class ExportManager:
return "\n".join(svg_parts)
def export_knowledge_graph_png(
self, project_id: str, entities: List[ExportEntity], relations: List[ExportRelation]
self, project_id: str, entities: list[ExportEntity], relations: list[ExportRelation]
) -> bytes:
"""
导出知识图谱为 PNG 格式
@@ -226,7 +233,7 @@ class ExportManager:
svg_content = self.export_knowledge_graph_svg(project_id, entities, relations)
return base64.b64encode(svg_content.encode("utf-8"))
def export_entities_excel(self, entities: List[ExportEntity]) -> bytes:
def export_entities_excel(self, entities: list[ExportEntity]) -> bytes:
"""
导出实体数据为 Excel 格式
@@ -275,7 +282,7 @@ class ExportManager:
return output.getvalue()
def export_entities_csv(self, entities: List[ExportEntity]) -> str:
def export_entities_csv(self, entities: list[ExportEntity]) -> str:
"""
导出实体数据为 CSV 格式
@@ -306,7 +313,7 @@ class ExportManager:
return output.getvalue()
def export_relations_csv(self, relations: List[ExportRelation]) -> str:
def export_relations_csv(self, relations: list[ExportRelation]) -> str:
"""
导出关系数据为 CSV 格式
@@ -324,7 +331,7 @@ class ExportManager:
return output.getvalue()
def export_transcript_markdown(self, transcript: ExportTranscript, entities_map: Dict[str, ExportEntity]) -> str:
def export_transcript_markdown(self, transcript: ExportTranscript, entities_map: dict[str, ExportEntity]) -> str:
"""
导出转录文本为 Markdown 格式
@@ -387,9 +394,9 @@ class ExportManager:
self,
project_id: str,
project_name: str,
entities: List[ExportEntity],
relations: List[ExportRelation],
transcripts: List[ExportTranscript],
entities: list[ExportEntity],
relations: list[ExportRelation],
transcripts: list[ExportTranscript],
summary: str = "",
) -> bytes:
"""
@@ -529,9 +536,9 @@ class ExportManager:
self,
project_id: str,
project_name: str,
entities: List[ExportEntity],
relations: List[ExportRelation],
transcripts: List[ExportTranscript],
entities: list[ExportEntity],
relations: list[ExportRelation],
transcripts: list[ExportTranscript],
) -> str:
"""
导出完整项目数据为 JSON 格式