f6feab9243
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).
40 lines
969 B
Python
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")
|