Files
OnebotCatalog/onebot-data/tools/copy-clamp-step.py
wangruiguo 0584ba67b4 v1.0: 夹紧缸模块真实数据替换 + 仓库瘦身
数据 (CLM 气动夹紧缸分类):
- 1 系列 demo -> 11 个官方系列, 6 型号 -> 859 个真实型号
- 参数化升级: 仅缸径 -> 最多 5 维 (缸径/臂位置/臂类型/臂样式/传感器)
- 11 系列各含官方图册附图 (84 张) + datasheet PDF
- 修复: 枚举维度空串必须为合法值 (否则级联过滤后下拉全空)
- 修复: catalog.json 分类 series 数组未更新导致新系列不进包
- 修复: _step 副本后缀归一化错误 (产生假型号)

工具:
- gen-clamp-series.py     数据清洗 (X盘数模 -> CSV/meta/STEP)
- copy-clamp-step.py      8线程并行复制 (网络盘 I/O 优化)
- gen-clamp-manual.py     官方图册 PDF -> 附图
- update-clamp-meta-attach.py / fix-clamp-meta-empty-enum.py

仓库瘦身:
- .gitignore 排除数模(5GB)/.opc(1.2GB)/编译产物/发布产物
- 移出索引: release/ bin产物 STEP数模 .opc 大型PDF 等
- 提交体积 17MB (原 15.97GB)

其他: SelfTest.cs 可解析选型逻辑放宽 (稀疏数据用真实变体回验)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-14 15:24:16 +08:00

45 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
"""并行复制夹紧缸 STEP 文件(去重后)到 catalog/step/,用归一化 .step 命名。"""
import os, sys, shutil, collections
from concurrent.futures import ThreadPoolExecutor, as_completed
sys.path.insert(0, os.path.dirname(__file__))
# 复用 gen-clamp-series 的 collect()(仅复制,不重写 CSV/meta)
import importlib.util
spec = importlib.util.spec_from_file_location('gcs', os.path.join(os.path.dirname(__file__), 'gen-clamp-series.py'))
gcs = importlib.util.module_from_spec(spec)
spec.loader.exec_module(gcs)
DST = r'D:/开发/OnebotCatalog/onebot-data/catalog/step'
os.makedirs(DST, exist_ok=True)
models = gcs.collect()
print(f'去重后需复制 {len(models)} 个文件')
todo = []
for m in models.values():
dst = os.path.join(DST, m['model'] + '.step')
if not os.path.exists(dst):
todo.append((m['src'], dst, m['model']))
print(f'尚未复制 {len(todo)} 个')
def cp(item):
src, dst, model = item
try:
shutil.copy2(src, dst)
return (model, 'ok', None)
except Exception as e:
return (model, 'err', str(e))
done = 0
with ThreadPoolExecutor(max_workers=8) as ex:
futs = [ex.submit(cp, it) for it in todo]
for fut in as_completed(futs):
model, status, err = fut.result()
done += 1
if status == 'err':
print(f'[ERR] {model}: {err}')
elif done % 50 == 0:
print(f' 进度 {done}/{len(todo)}')
print(f'完成,共复制 {done} 个文件')