1
0
mirror of https://github.com/minoplhy/filters-maker.git synced 2024-12-22 18:18:13 +00:00

create list and convert to tuple

This commit is contained in:
minoplhy 2021-08-11 12:21:31 +07:00
parent 7c6893cae4
commit 9e881cb571
2 changed files with 6 additions and 3 deletions

View File

@ -19,12 +19,13 @@ def download_filters(url,incoming):
return url
def filtering(filters_welcome):
unwanted = ['#',';','@','$',' NS',' NS','@@||','!']
print("filtering . . .")
with open(filters_welcome, 'r') as f:
lines = f.read().splitlines()
with open(filters_welcome, 'w') as f:
for line in lines:
if not line.startswith(('#',';','@','$',' NS',' NS','@@||','!')) and line.strip():
if not line.startswith((tuple(unwanted))) and line.strip():
f.write('\n'.join([line + '\n']))
print("++ successful!")
f.close()
@ -89,6 +90,7 @@ def killingdup(duplicated_file):
f.close()
def excluded(excluded ,incoming):
exline = [';','$','@',' IN']
with open(excluded ,'r') as f:
exclude = f.read().split()
with open(incoming ,'r') as f:
@ -97,7 +99,7 @@ def excluded(excluded ,incoming):
for line in lines:
if line.strip() and not line in exclude and not line.startswith(';'):
f.write('\n'.join([line + '\n']))
elif line.startswith((';','$','@',' IN')):
elif line.startswith((tuple(exline))):
f.write('\n'.join([line + '\n']))
elif not line.strip():
f.write('\n'.join([line + '\n']))

View File

@ -13,6 +13,7 @@ def add(incoming,userinput):
crawler.sort(incoming)
def add_file(incoming,excluded_in):
comment_roc = ['#',';','!']
data= ""
with open(incoming) as fp:
data = fp.read()
@ -29,7 +30,7 @@ def add_file(incoming,excluded_in):
lines = f.read().split()
with open(incoming ,'w') as f:
for line in lines:
if line.strip():
if line.strip() and not line.startswith((tuple(comment_roc))):
f.write('\n'.join([line + '\n']))
crawler.sort(incoming)
os.remove(excluded_in)