Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % git diff parse.py
- diff --git a/parse.py b/parse.py
- old mode 100644
- new mode 100755
- index 2ba445e..368c3b4
- --- a/parse.py
- +++ b/parse.py
- @@ -5,6 +5,7 @@ from xml.dom.minidom import *
- import codecs, sys
- import os
- import tempfile
- +import ipaddress
- # Функция для записи в файл списка
- @@ -17,6 +18,15 @@ import tempfile
- # with MyFile:
- # MyFile.write("\n".join(MyList))
- # MyFile.close()
- +def normalize_filedomain():
- + with open("_filedomain_.txt") as badfile, open("filedomain.txt", "w") as newfile:
- + for line in badfile:
- + try:
- + ipaddress.ip_address(line.strip())
- + continue
- + except:
- + newfile.writelines(line)
- +
- if os.path.exists("dump.xml"):
- xml = parse("dump.xml")
- @@ -26,7 +36,7 @@ else:
- # Список доменов
- try:
- - filedomain = open("filedomain.txt", "w")
- + filedomain = open("_filedomain_.txt", "w")
- except IOError as e:
- print("не удалось открыть файл")
- @@ -241,3 +251,5 @@ file_ipv6_resolv.close()
- file_ip_subnet.close()
- # Список ipv6 сетей для блокирования rip, zapret
- file_ipv6_subnet.close()
- +
- +normalize_filedomain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement