-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
import.py
28 lines (22 loc) · 895 Bytes
/
import.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
import os
import sys
import pyfiglet
from modules.validate import validate_record
from modules.clean import format_record
from modules.status import can_be_added
from modules.update import update_blocklists
os.system('cls' if os.name == 'nt' else 'clear')
print(pyfiglet.figlet_format("IMPORT", font="banner3-D"))
# This function will import records from a file into the blocklist.
if __name__ == '__main__':
args = sys.argv
with open(args[1], 'r') as file:
records = [line.strip() for line in file if not line.startswith('! ')]
with open('blocklist.txt', 'a') as blocklist_file:
for record in records:
record = format_record(record)
if not validate_record(record):
continue
if not can_be_added(record):
continue
blocklist_file.write(record + '\n')