-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_all_emojis.py
More file actions
66 lines (54 loc) Β· 2.59 KB
/
fix_all_emojis.py
File metadata and controls
66 lines (54 loc) Β· 2.59 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
60
61
62
63
64
65
66
"""
Comprehensive fix for all emoji syntax errors in integrated_gui.py
"""
import re
def fix_all_emojis():
"""Remove all problematic emoji characters that cause syntax errors"""
print("π§ Fixing emoji syntax errors in integrated_gui.py...")
# Read the file
with open("integrated_gui.py", "r", encoding="utf-8") as f:
content = f.read()
# Define emoji replacements to fix syntax errors
emoji_fixes = {
# Specific problematic emojis found in error messages
"π The API is free with generous limits!": "The API is free with generous limits!",
"π Your key is stored securely on your computer.": "Your key is stored securely on your computer.",
"π Translation Completed Successfully!": "Translation Completed Successfully!",
# Common problematic patterns
"π": "", # Party emoji
"π": "", # Free emoji
"π": "", # Lock emoji
# Fix any other potential issues
"f\"\"\"π": "f\"\"\"",
"f'''π": "f'''",
"\"π": "\"",
"'π": "'",
}
# Apply fixes
for old, new in emoji_fixes.items():
if old in content:
content = content.replace(old, new)
print(f"β
Fixed: {old[:20]}...")
# Use regex to find and replace any remaining problematic emoji patterns in f-strings
# This targets emojis at the start of f-strings which cause syntax errors
content = re.sub(r'f"""[ππππ΅π€ποΈπβ‘πΎπβ¨πΌπ―]+\s*', 'f"""', content)
content = re.sub(r"f'''[ππππ΅π€ποΈπβ‘πΎπβ¨πΌπ―]+\s*", "f'''", content)
content = re.sub(r'f"[ππππ΅π€ποΈπβ‘πΎπβ¨πΌπ―]+\s*', 'f"', content)
content = re.sub(r"f'[ππππ΅π€ποΈπβ‘πΎπβ¨πΌπ―]+\s*", "f'", content)
# Write back the fixed content
with open("integrated_gui.py", "w", encoding="utf-8") as f:
f.write(content)
print("β
All emoji syntax errors fixed!")
print("π integrated_gui.py is now ready to run!")
# Verify the fix by trying to compile the file
try:
with open("integrated_gui.py", "r", encoding="utf-8") as f:
compile(f.read(), "integrated_gui.py", "exec")
print("β
Syntax validation passed - file is now valid Python!")
except SyntaxError as e:
print(f"β οΈ Still has syntax error: {e}")
print(f"Line {e.lineno}: {e.text}")
except Exception as e:
print(f"β οΈ Other error: {e}")
if __name__ == "__main__":
fix_all_emojis()