Advertisement
smithy1208

Untitled

May 5th, 2023
1,621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.28 KB | None | 0 0
  1. % git diff parse.py
  2. diff --git a/parse.py b/parse.py
  3. old mode 100644
  4. new mode 100755
  5. index 2ba445e..368c3b4
  6. --- a/parse.py
  7. +++ b/parse.py
  8. @@ -5,6 +5,7 @@ from xml.dom.minidom import *
  9.  import codecs, sys
  10.  import os
  11.  import tempfile
  12. +import ipaddress
  13.  
  14.  
  15.  # Функция для записи в файл списка
  16. @@ -17,6 +18,15 @@ import tempfile
  17.  #              with MyFile:
  18.  #                      MyFile.write("\n".join(MyList))
  19.  #      MyFile.close()
  20. +def normalize_filedomain():
  21. +    with open("_filedomain_.txt") as badfile, open("filedomain.txt", "w") as newfile:
  22. +        for line in badfile:
  23. +            try:
  24. +                ipaddress.ip_address(line.strip())
  25. +                continue
  26. +            except:
  27. +                newfile.writelines(line)
  28. +
  29.  
  30.  if os.path.exists("dump.xml"):
  31.      xml = parse("dump.xml")
  32. @@ -26,7 +36,7 @@ else:
  33.  
  34.  # Список доменов
  35.  try:
  36. -    filedomain = open("filedomain.txt", "w")
  37. +    filedomain = open("_filedomain_.txt", "w")
  38.  except IOError as e:
  39.      print("не удалось открыть файл")
  40.  
  41. @@ -241,3 +251,5 @@ file_ipv6_resolv.close()
  42.  file_ip_subnet.close()
  43.  # Список ipv6 сетей для блокирования rip, zapret
  44.  file_ipv6_subnet.close()
  45. +
  46. +normalize_filedomain()
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement