report_generation/services/docx_export_service.py
xxy aa98ea2623 @
Initial commit

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
2026-06-05 18:45:29 +08:00

29 lines
786 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
services/docx_export_service.py瘦身版
本独立服务不提供 Word 导出能力;此处仅保留 report_generation_service 在
正文小节编号识别时懒加载依赖的 `_is_likely_section_number`,以满足导入。
"""
from __future__ import annotations
import re
def _is_likely_section_number(num: str) -> bool:
"""报告小节编号(如 2.1.1),非正文能耗数值(如 132.41)。"""
s = str(num or "").strip()
if not s or not re.fullmatch(r"\d+(?:\.\d+)*", s):
return False
parts = s.split(".")
if len(parts) > 4:
return False
for part in parts:
try:
n = int(part)
except ValueError:
return False
if n < 1 or n > 30:
return False
return True