# -*- coding: utf-8 -*- """ 勘察未完成分类的真实数模(定位销/勾销缸/翻转缸/夹爪缸/电缸) 用法: PYTHONUTF8=1 python scan-pending-series.py """ import os, re, collections, sys BASE = r'X:/新开发产品-Research and Development/1_产品3D数模(发客户仿真)' # 各分类的数据源目录 ROOTS = { 'PIN': ['2-伸缩销', '2019 Math Data 铁臂', '2019-NEW product', '2020UNICLAMP数模汇总'], 'HOK': ['3-勾销缸'], 'ROT': ['4-翻转缸'], 'GRP': ['5-夹臂', 'GR8_REV02'], 'ELEC': ['1-夹紧缸/电缸'], } # 关注的系列前缀(新码 UL* / US* / UAGP / UGP / LAE) FOCUS = re.compile(r'^(UL[A-Z]|US[A-Z]?|UAGP|UGP|LAE|LAGP|UAG)') def scan(dirs): found = collections.defaultdict(list) for d in dirs: root = os.path.join(BASE, d) if not os.path.isdir(root): continue for dirpath, _, files in os.walk(root): for f in files: if f.lower().endswith(('.stp', '.step')): found[f].append(os.path.join(dirpath, f)) return found def main(): for cat, dirs in ROOTS.items(): print(f'\n{"="*70}\n### {cat} (源: {", ".join(dirs)})\n{"="*70}') files = scan(dirs) buckets = collections.defaultdict(set) for fname in files: stem = os.path.splitext(fname)[0].upper().strip() m = FOCUS.match(stem) if not m: continue pfx = m.group(1) buckets[pfx].add(stem) for pfx in sorted(buckets): names = sorted(buckets[pfx]) print(f'\n -- {pfx} ({len(names)} 个)') for n in names[:200]: print(f' {n}') if len(names) > 200: print(f' ... 还有 {len(names)-200} 个') if __name__ == '__main__': main()