# -*- coding: utf-8 -*- import os, re targets = [ r'E:\mcsd\MCStudio', r'E:\MCStudioDownload\game', ] needles = ['缺少Manifest', 'Manifest配置', 'ManifestConfig', 'missing manifest', 'no manifest'] exts = ('.py', '.txt', '.json', '.lang', '.lua', '.js', '.xml', '.ini', '.cfg', '.md') encs = ['utf-8', 'gbk', 'utf-16'] hits = [] for root in targets: for dp, dn, fn in os.walk(root): # skip heavy dirs if any(s in dp.lower() for s in ('\\temp', '\\cache', '\\__pycache__')): continue for n in fn: if not n.lower().endswith(exts): continue p = os.path.join(dp, n) try: if os.path.getsize(p) > 5_000_000: continue raw = open(p, 'rb').read() except Exception: continue for enc in encs: try: t = raw.decode(enc) except Exception: continue for nd in needles: if nd in t: hits.append('%s [%s] %s' % (p, enc, nd)) break break with open(r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\0aaaa4f2f16c46e8964025a5ab0ecc02\_sa_hanhua_out\_tmp\grep_manifest.txt', 'w', encoding='utf-8') as f: f.write('\n'.join(hits) if hits else 'NO HITS') print('hits=%d' % len(hits))