@@ -74,6 +74,20 @@ def parse_arguments():
74
74
)
75
75
return parser .parse_args ()
76
76
77
+ def load_excluded_names (script_dir : Path ) -> set :
78
+ """Load names to exclude from the lostnames file."""
79
+ lostnames_file = script_dir / "lostnames"
80
+ excluded_names = set ()
81
+
82
+ if lostnames_file .exists ():
83
+ with open (lostnames_file , 'r' ) as f :
84
+ for line in f :
85
+ name = line .strip ()
86
+ if name :
87
+ excluded_names .add (name .lower ()) # Store in lowercase for case-insensitive comparison
88
+
89
+ return excluded_names
90
+
77
91
def main ():
78
92
"""Main function to generate the CSV file."""
79
93
@@ -83,12 +97,17 @@ def main():
83
97
# Path to the input and output files
84
98
input_file = Path (args .input_file )
85
99
output_file = Path (args .output )
100
+ script_dir = Path (__file__ ).parent
86
101
87
102
# Check if input file exists
88
103
if not input_file .exists ():
89
104
print (f"Error: Input file '{ input_file } ' not found." )
90
105
return 1
91
106
107
+ # Load excluded names from lostnames file
108
+ excluded_names = load_excluded_names (script_dir )
109
+ print (f"Loaded { len (excluded_names )} excluded names from lostnames file" )
110
+
92
111
# Calculate duration in seconds
93
112
duration_seconds = calculate_duration_in_seconds (args .duration )
94
113
print (f"Duration: { args .duration } years ({ duration_seconds } seconds)" )
@@ -99,11 +118,17 @@ def main():
99
118
seen_ids = set ()
100
119
unique_entries = []
101
120
duplicate_names = []
121
+ excluded_names_found = []
102
122
103
123
with open (input_file , 'r' ) as infile :
104
124
for line_num , line in enumerate (infile , 1 ):
105
125
name = line .strip ()
106
126
if name : # Skip empty lines
127
+ # Check if name is in excluded list (case-insensitive)
128
+ if name .lower () in excluded_names :
129
+ excluded_names_found .append ((line_num , name ))
130
+ continue
131
+
107
132
name_id = keccak256_to_uint (name )
108
133
if name_id not in seen_ids :
109
134
seen_ids .add (name_id )
@@ -126,18 +151,27 @@ def main():
126
151
total_names = sum (1 for line in open (input_file ) if line .strip ())
127
152
unique_count = len (unique_entries )
128
153
duplicate_count = len (duplicate_names )
154
+ excluded_count = len (excluded_names_found )
129
155
130
156
print (f"CSV file generated: { output_file } " )
131
157
print (f"Total names processed: { total_names } " )
132
158
print (f"Unique entries written: { unique_count } " )
133
159
print (f"Duplicates found and skipped: { duplicate_count } " )
160
+ print (f"Excluded names found and skipped: { excluded_count } " )
134
161
135
162
if duplicate_names :
136
163
print ("\n Duplicate names found:" )
137
164
for line_num , name in duplicate_names :
138
165
print (f" Line { line_num } : { name } " )
139
166
else :
140
167
print ("No duplicates found." )
168
+
169
+ if excluded_names_found :
170
+ print ("\n Excluded names found (from lostnames):" )
171
+ for line_num , name in excluded_names_found :
172
+ print (f" Line { line_num } : { name } " )
173
+ else :
174
+ print ("No excluded names found." )
141
175
return 0
142
176
143
177
if __name__ == "__main__" :
0 commit comments