Files
vpn-rules/scripts/gen_plain_list.py
T

26 lines
826 B
Python
Raw 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.
#!/usr/bin/env python3
"""从 direct.yaml(真源)生成无 `- ` 前缀的纯文本规则列表。
格式:每条规则一行,无 YAML 列表前缀、无注释、无策略字段
(同 rule-provider payload 内容,只是去掉 `- `)。
适用于把规则直接粘贴进不支持 YAML 列表 / 不需要策略前缀的工具。
"""
from pathlib import Path
from gen_clash_verge_script import load_payload
REPO_ROOT = Path(__file__).resolve().parent.parent
OUT = REPO_ROOT / "router" / "direct-plain.txt"
def main() -> None:
payload = load_payload(REPO_ROOT / "direct.yaml")
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text("\n".join(payload) + "\n", encoding="utf-8")
print(f"✅ 已生成 {OUT}({len(payload)} 条规则,无 - 前缀)")
if __name__ == "__main__":
main()