mavzermete 1
mavzermete
xranzei 1
xranzei
Manwe Work 1
Manwe Work
noisiv 1
noisiv
Hikaye Ekle

Client Source C++17 yapma

  • Konuyu başlatan Konuyu başlatan mgurbet1998
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 1
  • Görüntüleme Görüntüleme 343
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. 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::pair'),
(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...

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst