-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_regex_final2.py
More file actions
40 lines (30 loc) · 1.44 KB
/
fix_regex_final2.py
File metadata and controls
40 lines (30 loc) · 1.44 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# خواندن فایل
with open('backend/ai_module/gapgpt_client.py', 'r', encoding='utf-8') as f:
content = f.read()
# تغییر الگوها
old1 = r"remaining_match = re.search(r'(?:remain|remaining)[\s_]?quota[::\s]*\$?\??([\d.]+)', error_msg, re.IGNORECASE)"
new1 = r"remaining_match = re.search(r'(?:remain|remaining)\s+quota[::\s]*\s*\??([\d.]+)', error_msg, re.IGNORECASE)"
old2 = r"required_match = re.search(r'need[\s_]?quota[::\s]*\$?\??([\d.]+)', error_msg, re.IGNORECASE)"
new2 = r"required_match = re.search(r'need\s+quota[::\s]*\s*\??([\d.]+)', error_msg, re.IGNORECASE)"
content = content.replace(old1, new1)
content = content.replace(old2, new2)
# ذخیره فایل
with open('backend/ai_module/gapgpt_client.py', 'w', encoding='utf-8') as f:
f.write(content)
print("✓ Fixed gapgpt_client.py")
# همین کار را برای فایلهای دیگر
for file_path in ['backend/ai_module/providers/__init__.py', 'backend/ai_module/provider_manager.py']:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
original = content
content = content.replace(old1, new1)
content = content.replace(old2, new2)
if content != original:
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"✓ Fixed {file_path}")
else:
print(f"- No changes in {file_path}")
print("Done!")