Skip to content

Commit

Permalink
sort script still not running fine
Browse files Browse the repository at this point in the history
  • Loading branch information
spirillen committed Jan 19, 2025
1 parent ea00132 commit 2b09c64
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/sort_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import dns.resolver
import dns.query

VERSION = "0.2b17" # Incremented beta version
VERSION = "0.2b18" # Incremented beta version

def find_files_by_name(directory, filenames):
matches = []
Expand Down Expand Up @@ -133,7 +133,8 @@ def sort_file_alphanum(file_path, valid_tlds, proxy):
lines = remove_duplicates(lines) # Remove duplicate lines

header = lines[0] if lines else ""
lines = [line for line in lines[1:] if line.strip()] # Remove empty lines and skip header if present
lines = [line.rstrip('\n') for line in lines[1:] if line.strip()] # Remove empty lines and skip header

lines = sorted(lines, key=lambda x: x.strip().split(',')[0] if ',' in x else '') # Sort FQDNs

invalid_entries = []
Expand All @@ -149,6 +150,13 @@ def sort_file_alphanum(file_path, valid_tlds, proxy):
for entry in invalid_entries:
print(entry.strip())

with open(file_path, 'w') as file:
if header:
file.write(header)
file.write('\n'.join(lines))
file.write('\n') # Ensure a newline at the end of the file


def sort_file_tld(file_path, valid_tlds, proxy):
with open(file_path, 'r') as file:
lines = file.readlines()
Expand Down

0 comments on commit 2b09c64

Please sign in to comment.