-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_indentation.py
More file actions
59 lines (50 loc) · 2.21 KB
/
fix_indentation.py
File metadata and controls
59 lines (50 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Quick fix for kokoro_tts.py indentation issues
"""
def fix_indentation():
"""Fix the indentation issues in kokoro_tts.py"""
with open('core/kokoro_tts.py', 'r', encoding='utf-8') as f:
lines = f.readlines()
# Fix the specific indentation issues
fixed_lines = []
in_class = False
in_method = False
for i, line in enumerate(lines):
# Check if we're entering the class
if line.strip().startswith('class KokoroTTSEngine:'):
in_class = True
fixed_lines.append(line)
continue
# If we're in the class, fix indentation
if in_class:
# Check for method definitions
if line.strip().startswith('def '):
# Method definition - should be indented 4 spaces from class
fixed_line = ' ' + line.strip() + '\n'
fixed_lines.append(fixed_line)
in_method = True
continue
elif line.strip().startswith('"""') and in_method:
# Docstring - should be indented 8 spaces from class
fixed_line = ' ' + line.strip() + '\n'
fixed_lines.append(fixed_line)
continue
elif line.strip() and not line.startswith(' ') and not line.startswith('\t'):
# End of class
in_class = False
in_method = False
fixed_lines.append(line)
continue
elif line.strip().startswith('self.') or line.strip().startswith('logger.') or line.strip().startswith('return ') or line.strip().startswith('if ') or line.strip().startswith('try:') or line.strip().startswith('except'):
# Method content - should be indented 8 spaces from class
fixed_line = ' ' + line.strip() + '\n'
fixed_lines.append(fixed_line)
continue
# For everything else, keep as is
fixed_lines.append(line)
# Write back
with open('core/kokoro_tts.py', 'w', encoding='utf-8') as f:
f.writelines(fixed_lines)
print("Indentation fixed in kokoro_tts.py")
if __name__ == "__main__":
fix_indentation()