- Katılım
- 22 Eki 2024
- Konular
- 27
- Mesajlar
- 268
- Online süresi
- 1mo 3d
- Reaksiyon Skoru
- 166
- Altın Konu
- 0
- Başarım Puanı
- 74
- MmoLira
- 2,281
- DevLira
- 42
ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ HEMEN TIKLA!
Anlatım hazırlayacağım devamı gelecek.
[CODE lang="python" title="std::"]import os
import re
def read_file_with_fallback(file_path):
encodings = ['utf-8', 'latin-1', 'cp1252']
for enc in encodings:
try:
with open(file_path, 'r', encoding=enc) as file:
return file.readlines(), enc
except UnicodeDecodeError:
continue
raise UnicodeDecodeError(f"Dosya {file_path} uygun bir şekilde okunamadı.")
def convert_to_std_syntax(file_path):
lines, encoding_used = read_file_with_fallback(file_path)
replacements = [
(r'(?<!std:
(?<!\w)(string)(?!\w)', r'std::string'),
(r'(?<!std:
(?<!\w)(pair)(?!\w)', r'std:
air'),
(r'(?<!std:
(?<!\w)(make_pair)(?!\w)', r'std::make_pair'),
(r'(?<!std:
(?<!\w)(vector)(?!\w)', r'std::vector'),
]
updated_lines = []
for line in lines:
if line.strip().startswith("#include"):
updated_lines.append(line)
continue
for pattern, replacement in replacements:
line = re.sub(pattern, replacement, line)
updated_lines.append(line)
with open(file_path, 'w', encoding=encoding_used) as file:
file.writelines(updated_lines)
def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(('.cpp', '.h')):
file_path = os.path.join(root, file)
print(f"Processing: {file_path}")
try:
convert_to_std_syntax(file_path)
except Exception as e:
print(f"Hata oluştu: {e} (Dosya: {file_path})")
project_directory = "."
process_directory(project_directory)
[/CODE]
[CODE lang="python" title="std::"]import os
import re
def read_file_with_fallback(file_path):
encodings = ['utf-8', 'latin-1', 'cp1252']
for enc in encodings:
try:
with open(file_path, 'r', encoding=enc) as file:
return file.readlines(), enc
except UnicodeDecodeError:
continue
raise UnicodeDecodeError(f"Dosya {file_path} uygun bir şekilde okunamadı.")
def convert_to_std_syntax(file_path):
lines, encoding_used = read_file_with_fallback(file_path)
replacements = [
(r'(?<!std:
(?<!\w)(string)(?!\w)', r'std::string'),(r'(?<!std:
(?<!\w)(pair)(?!\w)', r'std:
air'),(r'(?<!std:
(?<!\w)(make_pair)(?!\w)', r'std::make_pair'),(r'(?<!std:
(?<!\w)(vector)(?!\w)', r'std::vector'),]
updated_lines = []
for line in lines:
if line.strip().startswith("#include"):
updated_lines.append(line)
continue
for pattern, replacement in replacements:
line = re.sub(pattern, replacement, line)
updated_lines.append(line)
with open(file_path, 'w', encoding=encoding_used) as file:
file.writelines(updated_lines)
def process_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(('.cpp', '.h')):
file_path = os.path.join(root, file)
print(f"Processing: {file_path}")
try:
convert_to_std_syntax(file_path)
except Exception as e:
print(f"Hata oluştu: {e} (Dosya: {file_path})")
project_directory = "."
process_directory(project_directory)
[/CODE]
- Durum
- Üzgünüz bu konu cevaplar için kapatılmıştır...



