29 lines
786 B
Python
29 lines
786 B
Python
"""
|
||
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
|