wip: 2026-08-11 工作树快照(docs/memory/h5.py/scripts 等 447 项未评审改动,安全提交到 feat 分支)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""删除已清空的旧独有目录(含递归空子目录)。仅删确认为空的目录,杜绝误删新结构内容。"""
|
||||
import os, shutil, sys
|
||||
|
||||
ROOT = "docs"
|
||||
DRY = "--go" not in sys.argv
|
||||
|
||||
# 旧独有目录(非规范 9 类,规范类为 01-产品文档/02-技术文档/03-测试文档/04-运维文档/05-运营文档/06-安全审计/07-项目管理/08-历史归档)
|
||||
OLD_ONLY = [
|
||||
"01-产品设计", "02-产品需求", "03-技术架构", "04-原型设计",
|
||||
"06-测试质量", "08-安全审计", "09-部署运维", "10-项目管理", "11-历史归档",
|
||||
]
|
||||
|
||||
print("校验 9 个旧独有目录是否为空:")
|
||||
all_empty = True
|
||||
for d in OLD_ONLY:
|
||||
dp = os.path.join(ROOT, d)
|
||||
if not os.path.isdir(dp):
|
||||
print(" 跳过(不存在):", d); continue
|
||||
n = sum(1 for _ in os.walk(dp) if False) # placeholder
|
||||
files = []
|
||||
for root, dirs, fnames in os.walk(dp):
|
||||
for f in fnames:
|
||||
files.append(os.path.join(root, f))
|
||||
print(" %s : %d 个文件" % (d, len(files)))
|
||||
if files:
|
||||
all_empty = False
|
||||
for f in files[:10]:
|
||||
print(" 残留:", f)
|
||||
|
||||
if not all_empty:
|
||||
print("\n!! 存在残留文件,终止删除,请人工核查。")
|
||||
raise SystemExit(1)
|
||||
|
||||
print("\n✓ 全部为空,可安全删除" if not DRY else "\n[DRY] 以下将递归删除:")
|
||||
if DRY:
|
||||
for d in OLD_ONLY:
|
||||
print(" ", d)
|
||||
else:
|
||||
for d in OLD_ONLY:
|
||||
dp = os.path.join(ROOT, d)
|
||||
if os.path.isdir(dp):
|
||||
shutil.rmtree(dp)
|
||||
print(" 已删除:", d)
|
||||
print("\n删除完成。")
|
||||
Reference in New Issue
Block a user