wip: 2026-08-11 工作树快照(docs/memory/h5.py/scripts 等 447 项未评审改动,安全提交到 feat 分支)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""对 24 个残留旧引用,尝试在当前新结构里找近似等价文件。"""
|
||||
import os, re, collections
|
||||
|
||||
ROOT = "docs"
|
||||
OLD_DIRS = ["02-产品需求", "03-技术架构", "04-原型设计",
|
||||
"09-部署运维", "10-项目管理", "01-产品设计", "06-测试质量"]
|
||||
|
||||
# 当前 docs 全部文件相对路径
|
||||
allfiles = []
|
||||
for root, _, fs in os.walk(ROOT):
|
||||
for f in fs:
|
||||
rel = os.path.relpath(os.path.join(root, f), ROOT).replace(os.sep, '/')
|
||||
allfiles.append(rel)
|
||||
|
||||
pat = re.compile(r'(?:%s)/[^\s\)\]]+' % '|'.join(OLD_DIRS))
|
||||
residual = {} # basename -> oldref (去尾反引号)
|
||||
for root, _, fs in os.walk(ROOT):
|
||||
for f in fs:
|
||||
if not f.endswith('.md'):
|
||||
continue
|
||||
with open(os.path.join(root, f), encoding='utf-8') as fh:
|
||||
for line in fh:
|
||||
for m in pat.finditer(line):
|
||||
oldref = m.group(0).rstrip('`')
|
||||
bn = oldref.split('/')[-1]
|
||||
residual.setdefault(bn, oldref)
|
||||
|
||||
def candidates(bn):
|
||||
# 关键词:去掉版本/日期/扩展名,取核心词
|
||||
core = re.sub(r'[-_ ]?(v?\d+\.\d+.*|2026\d\d\d\d|\d{8}|备份|archived).*$', '', bn)
|
||||
core = core.replace('.md', '').replace('.html', '')
|
||||
# 取连续中文/英文关键词片段
|
||||
keys = [k for k in re.split(r'[-_ ]', core) if len(k) >= 2]
|
||||
hits = []
|
||||
for af in allfiles:
|
||||
afb = af.split('/')[-1]
|
||||
if bn == afb:
|
||||
continue
|
||||
if any(k.lower() in afb.lower() for k in keys if len(k) >= 3):
|
||||
hits.append(af)
|
||||
return hits[:5]
|
||||
|
||||
print("残留 basename 数:", len(residual))
|
||||
for bn, oldref in sorted(residual.items()):
|
||||
if bn in ('', '`'):
|
||||
continue
|
||||
c = candidates(bn)
|
||||
print("\n● %s" % bn)
|
||||
print(" 旧: %s" % oldref)
|
||||
print(" 候选(新结构): " + ("; ".join(c) if c else "*** 无近似文件(确属死链) ***"))
|
||||
Reference in New Issue
Block a user