Files
manual_slop/scripts/standardize_indent.py
T
ed f6feab9243 fix(gui): Correct indentation bug in _render_mma_dashboard that caused crash
The code after the 'prior session' return block was incorrectly indented
at 1 space, placing it inside the 'if is_viewing_prior_session' block
instead of after it. This caused 'total_cost' and 'perc' to be undefined
when viewing an active session, triggering an IM_ASSERT error.

Fix: Moved 'track_name', 'track_stats', and 'total_cost' to the
correct 2-space indentation (method body level).
2026-05-06 19:41:22 -04:00

40 lines
969 B
Python

import sys
import os
def standardize_file(file_path):
try:
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
except Exception as e:
print(f"Error reading {file_path}: {e}")
return
new_lines = []
for line in lines:
stripped = line.lstrip(' ')
space_count = len(line) - len(stripped)
if space_count > 0 and space_count % 4 == 0:
new_space_count = space_count // 4
new_lines.append(' ' * new_space_count + stripped)
else:
new_lines.append(line)
try:
with open(file_path, 'w', encoding='utf-8') as f:
f.writelines(new_lines)
print(f"Standardized {file_path}")
except Exception as e:
print(f"Error writing {file_path}: {e}")
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python scripts/standardize_indent.py <file_path1> <file_path2> ...")
sys.exit(1)
for path in sys.argv[1:]:
if os.path.isfile(path):
standardize_file(path)
else:
print(f"Skipping {path}: Not a file")