From 0aa0c982faf93c73e267273b823008f7731a8c9a Mon Sep 17 00:00:00 2001 From: Minoplhy Date: Sun, 12 Dec 2021 17:20:24 +0700 Subject: [PATCH] Adguard Converter : Support some others regex --- to-rpz/adguard-host-wildcards_rpz_argv.py | 11 ++++++++++- to-rpz/adguard-host_rpz_argv.py | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/to-rpz/adguard-host-wildcards_rpz_argv.py b/to-rpz/adguard-host-wildcards_rpz_argv.py index cfef172..9fc333f 100644 --- a/to-rpz/adguard-host-wildcards_rpz_argv.py +++ b/to-rpz/adguard-host-wildcards_rpz_argv.py @@ -6,7 +6,16 @@ from shutil import copyfile infile = sys.argv[1] outfile = sys.argv[2] -a = ['||','^'] +with open(infile) as f: + file = f.read().split('\n') +for i in range(len(file)): + file[i] = re.sub('(..*#..*)|(@@\|\|..*)|(\|\|..*\/..*)|(^\/..*)|(^..*\$app=..*)|(^..*\$removeparam=..*)|(^..\/..*)|(\$..*)|(^\...*)|(^:..*)|(^\|http)|(^@@..*)|(^_..*)|(\*..*)', '', file[i]) +#print(file) +with open(infile, 'w') as f1: + f1.writelines(["%s\n" % item for item in file]) +f.close() + +a = ['||','^','|'] lst = [] with open(infile, 'r') as f: diff --git a/to-rpz/adguard-host_rpz_argv.py b/to-rpz/adguard-host_rpz_argv.py index a4f5ba7..00ccc1e 100644 --- a/to-rpz/adguard-host_rpz_argv.py +++ b/to-rpz/adguard-host_rpz_argv.py @@ -1,11 +1,20 @@ import os import sys -from re import sub +import re from shutil import copyfile infile = sys.argv[1] outfile = sys.argv[2] +with open(infile) as f: + file = f.read().split('\n') +for i in range(len(file)): + file[i] = re.sub('(..*#..*)|(@@\|\|..*)|(\|\|..*\/..*)|(^\/..*)|(^..*\$app=..*)|(^..*\$removeparam=..*)|(^..\/..*)|(\$..*)|(^\...*)|(^:..*)|(^\|http)|(^@@..*)|(^_..*)|(\*..*)', '', file[i]) +#print(file) +with open(infile, 'w') as f1: + f1.writelines(["%s\n" % item for item in file]) +f.close() + a = ['||','^','|'] lst = [] @@ -24,7 +33,7 @@ f.close() with open(infile) as f: file = f.read().split('\n') for i in range(len(file)): - file[i] = sub(r'!', ';', file[i]) + file[i] = re.sub(r'!', ';', file[i]) #print(file) with open(infile, 'w') as f1: f1.writelines(["%s\n" % item for item in file]) @@ -48,7 +57,7 @@ f.close() with open(infile) as f: file = f.read().split('\n') for i in range(len(file)): - file[i] = sub('^@@', '', file[i]) + file[i] = re.sub('^@@', '', file[i]) #print(file) with open(infile, 'w') as f1: f1.writelines(["%s\n" % item for item in file])