17 lines
708 B
Python
Executable File
17 lines
708 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""去掉 Clash Premium(Clash for Windows) 不认识的规则类型,保持镜像可被新旧内核共用。"""
|
|
import pathlib, re, sys
|
|
|
|
UNSUPPORTED = ("IP-ASN", "GEOSITE", "IP-SUFFIX", "SRC-IP-SUFFIX", "RULE-SET", "SUB-RULE", "AND", "OR", "NOT")
|
|
|
|
changed = 0
|
|
for f in sorted(pathlib.Path("rules").iterdir()):
|
|
lines = f.read_text(encoding="utf-8").splitlines(True)
|
|
kept = [l for l in lines
|
|
if not any(re.match(rf"\s*-\s*{t},", l) for t in UNSUPPORTED)]
|
|
if len(kept) != len(lines):
|
|
f.write_text("".join(kept), encoding="utf-8")
|
|
print(f"{f.name}: removed {len(lines) - len(kept)} line(s)")
|
|
changed += 1
|
|
print(f"files changed: {changed}")
|