_check_s1_styles.py 1009 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. """检查 S1 模板 docx 的表格样式/标题样式 ID/页面设置,供生成器复用。"""
  3. from __future__ import annotations
  4. import re
  5. import zipfile
  6. from pathlib import Path
  7. BASE = Path(r"C:\Users\skygu\OneDrive\Projects\AIDOP\项目\项目管理\产互联项目管理\交付文档\Release产互联")
  8. for name in [
  9. "S1产销协同业务需求描述-V0.4.docx",
  10. "S1产销协同模块蓝图设计方案-V2.2.docx",
  11. "S1产销协同模块详细设计说明书-V1.2.docx",
  12. "S1产销协同模块用户操作手册-V1.2.docx",
  13. ]:
  14. z = zipfile.ZipFile(BASE / name)
  15. xml = z.read("word/document.xml").decode("utf-8")
  16. tbl_styles = sorted(set(re.findall(r'<w:tblStyle w:val="([^"]+)"', xml)))
  17. p_styles = sorted(set(re.findall(r'<w:pStyle w:val="([^"]+)"', xml)))
  18. sect = re.search(r"<w:pgSz[^/]*/>", xml)
  19. print(name)
  20. print(" tblStyles:", tbl_styles)
  21. print(" pStyles:", p_styles[:20])
  22. print(" pgSz:", sect.group(0) if sect else None)