From 8504470a57b2828e6d72c25afb0cfe7d552bb128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B8=A2=E4=BD=8E=E5=90=B8?= Date: Mon, 10 Jul 2023 07:47:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=A4=9A=E7=A8=AE=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoBuild/builder.py | 17 +++++++++++++++-- AutoBuild/tw_165.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/AutoBuild/builder.py b/AutoBuild/builder.py index 84557d4..f79eeb8 100644 --- a/AutoBuild/builder.py +++ b/AutoBuild/builder.py @@ -80,12 +80,25 @@ for category in filterlist: f.write(newhead + domain_list) # hosts to domains - if filename == 'hosts.txt': + def to_pure_domain(filename: str, data: str): data = data.splitlines() newdata = '\n'.join(data[5:]) desc = '\n'.join(x.replace('!', '#') for x in data[:5]) + '\n' - with open('domains.txt', 'w') as output: + name = filename.split('.text')[0] + with open(name+'-domains.txt', 'w') as output: pattern = r'(?<=^\|\|)\S+\.\S{2,}(?=\^)' desc += '\n'.join(re.findall(pattern, newdata, re.MULTILINE)) output.write(desc) + if filename in ['hosts.txt', 'TW165.txt']: + to_pure_domain(filename, data) + + # if filename == 'hosts.txt': + # data = data.splitlines() + # newdata = '\n'.join(data[5:]) + # desc = '\n'.join(x.replace('!', '#') for x in data[:5]) + '\n' + + # with open('domains.txt', 'w') as output: + # pattern = r'(?<=^\|\|)\S+\.\S{2,}(?=\^)' + # desc += '\n'.join(re.findall(pattern, newdata, re.MULTILINE)) + # output.write(desc) \ No newline at end of file diff --git a/AutoBuild/tw_165.py b/AutoBuild/tw_165.py index ba5bb73..09d51de 100644 --- a/AutoBuild/tw_165.py +++ b/AutoBuild/tw_165.py @@ -53,7 +53,7 @@ def main(): filename = 'TW165.txt' with open(filename, 'w') as f: - f.write('\n'.join(domains.keys())) + f.write('^\n'.join('||' + e for e in domains.keys())) if __name__ == '__main__': main()