-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg2s.py
43 lines (35 loc) · 1.29 KB
/
g2s.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# gfwlist2shadowrocket
# g2s
#
# Created by wuwenhan on 18/10/2017.
# 03:24
# Copyright (c) 2017 wuwenhan. All rights reserved.
#
import argparse
from gfwlist_parser import GFWListParser
def build_args():
parser = argparse.ArgumentParser(description='Convert GFWList to '
'Shadowrocket config')
parser.add_argument('-g',
'--gfwlist',
type=argparse.FileType('w'),
default=None,
help='`gfwlist.txt` file path, this script will '
'download `gfwlist.txt` from GitHub if you '
'didn\'t specific this argument.')
parser.add_argument('-o',
'--output',
type=argparse.FileType('w'),
default='./shadowrocket.conf',
help='write documents to FILE, default '
'`shadowrocket.conf`')
return parser.parse_args()
def main():
args = build_args()
parser = GFWListParser(output=args.output.name,
gfwlist_path=args.gfwlist.name
if args.gfwlist else None)
parser.generate_conf()
if __name__ == '__main__':
main()