import sys import re def fix_gaps(): file_path = "src/gui_2.py" with open(file_path, "r", encoding="utf-8") as f: content = f.read() # Replace 3+ newlines with 2 newlines (one empty line) # Using \r\n for Windows support if needed, but \n is standard for Python reads content = re.sub(r"\n\n\n+", "\n\n", content) # Specific fix for regions: ensure no extra space after region start or before region end content = re.sub(r"(#region: .*)\n\n+", r"\1\n", content) content = re.sub(r"\n\n+(#endregion: .*)", r"\n\1", content) with open(file_path, "w", encoding="utf-8") as f: f.write(content) print("Whitespace gaps fixed.") if __name__ == "__main__": fix_gaps()