|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import re |
| 3 | + |
| 4 | +# Read the file |
| 5 | +with open('site/src/contexts/ProxyContext.tsx', 'r') as f: |
| 6 | + lines = f.readlines() |
| 7 | + |
| 8 | +# Fix the file line by line |
| 9 | +fixed_lines = [] |
| 10 | +i = 0 |
| 11 | +while i < len(lines): |
| 12 | + line = lines[i] |
| 13 | + |
| 14 | + # Fix line breaks in comments |
| 15 | + if 'comes fro\\' in line and i + 1 < len(lines) and 'm either:' in lines[i + 1]: |
| 16 | + fixed_lines.append(line.replace('comes fro\\', 'comes from either:')) |
| 17 | + i += 2 # Skip the next line |
| 18 | + continue |
| 19 | + elif line.strip() == 'm either:': |
| 20 | + i += 1 # Skip this line |
| 21 | + continue |
| 22 | + |
| 23 | + # Fix other line breaks |
| 24 | + if 'valu\\' in line and i + 1 < len(lines) and 'nes are sourced' in lines[i + 1]: |
| 25 | + fixed_lines.append(line.replace('valu\\', 'values are sourced')) |
| 26 | + i += 2 |
| 27 | + continue |
| 28 | + elif 'nes are sourced' in line.strip(): |
| 29 | + i += 1 |
| 30 | + continue |
| 31 | + |
| 32 | + if 'comes\n' in line and i + 1 < len(lines) and ' from local storage' in lines[i + 1]: |
| 33 | + fixed_lines.append(line.replace('comes\n', 'comes from local storage')) |
| 34 | + i += 2 |
| 35 | + continue |
| 36 | + elif line.strip() == ' from local storage': |
| 37 | + i += 1 |
| 38 | + continue |
| 39 | + |
| 40 | + if 'migrati\\' in line and i + 1 < len(lines) and 'on' in lines[i + 1]: |
| 41 | + fixed_lines.append(line.replace('migrati\\', 'migration')) |
| 42 | + i += 2 |
| 43 | + continue |
| 44 | + elif line.strip() == 'on' and i > 0 and 'migrati' in lines[i-1]: |
| 45 | + i += 1 |
| 46 | + continue |
| 47 | + |
| 48 | + # Fix indentation - replace 8 spaces with tabs at the beginning of lines |
| 49 | + if line.startswith(' '): |
| 50 | + line = line.replace(' ', '\t', 1) |
| 51 | + |
| 52 | + fixed_lines.append(line) |
| 53 | + i += 1 |
| 54 | + |
| 55 | +# Write the file back |
| 56 | +with open('site/src/contexts/ProxyContext.tsx', 'w') as f: |
| 57 | + f.writelines(fixed_lines) |
| 58 | + |
| 59 | +print("Fixed formatting issues") |
0 commit comments