# -*- coding: utf-8 -*- # t07-extract.py — 提取 A1X 各页需求批注区(含「开发说明」「页面类型」单元格全文) import io, sys, glob, re sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') base = '.scratch/opportunity-bugfix/lanhu-pages/' files = [ 'A1X-1_工作计划_工作日历.md', 'A1X-2_工作计划_计划管理.md', 'A1X-3_工作计划_出差与拜访.md', 'A1X-1-2_填写今日工作.md', 'A1X-1-3_工作计划详情.md', ] for fn in files: txt = open(base + fn, 'r', encoding='utf-8').read() print(f'\n===== {fn} =====') # 批注区单元格特征:含【页面类型】或【字段说明】或「开发说明」的表格行 hits = [ln for ln in txt.splitlines() if ('【页面类型】' in ln or '【字段说明】' in ln or '【交互规则】' in ln or '【验收标准】' in ln or '、开发说明' in ln or '、交互说明' in ln)] if not hits: # 退一步:找含「需求」「页面名称」等关键词的长行 hits = [ln for ln in txt.splitlines() if '页面名称' in ln and len(ln) > 200] for h in hits: # 表格行去掉前缀 | uNNN | 类型 | 名称 | m = re.search(r'\|\s*`?(.+)$', h) body = h[h.find('`') + 1:] if '`' in h else h print(body[:4000]) if not hits: print('(未找到批注区,页面控件数:', txt.count('| u'), ')') print('\ndone')