- Katılım
- 29 Eyl 2009
- Konular
- 1,298
- Mesajlar
- 18,700
- Çözüm
- 203
- Online süresi
- 7mo 19h
- Reaksiyon Skoru
- 9,275
- Altın Konu
- 377
- Başarım Puanı
- 426
- Yaş
- 32
- MmoLira
- 51,363
- DevLira
- 74
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!
Eline sağlık.
- Katılım
- 20 Ara 2023
- Konular
- 2
- Mesajlar
- 145
- Online süresi
- 25d 1h
- Reaksiyon Skoru
- 50
- Altın Konu
- 0
- TM Yaşı
- 2 Yıl 5 Ay 22 Gün
- Başarım Puanı
- 58
- MmoLira
- 3,035
- DevLira
- 3
Paylaşım için teşekkürler
- Katılım
- 12 Ara 2009
- Konular
- 133
- Mesajlar
- 2,071
- Online süresi
- 5d 17h
- Reaksiyon Skoru
- 143
- Altın Konu
- 1
- Başarım Puanı
- 177
- MmoLira
- 1,085
- DevLira
- 3
Eline sağlık.
- Katılım
- 13 Haz 2013
- Konular
- 182
- Mesajlar
- 2,499
- Çözüm
- 92
- Online süresi
- 3mo 20d
- Reaksiyon Skoru
- 1,662
- Altın Konu
- 2
- TM Yaşı
- 12 Yıl 12 Ay 3 Gün
- Başarım Puanı
- 284
- Yaş
- 28
- MmoLira
- 8,570
- DevLira
- 84
Paylaşım için teşekkürler, kodunda ufak tefek iyilleştirmeler yaptım. Regex ile precompiled bir pattern ile aramak çok daha performanslı olacaktır, ayrıca error handling kısmında hata alanlar için ekstra detaylar var.
Python:
import re
import os
try:
from pathlib import Path
except ImportError:
os.system("pip install pathlib")
from pathlib import Path
def load_item_names(item_names_filename: str) -> dict[str, str]:
item_names = {}
try:
with open(item_names_filename, "r", encoding="windows-1254", errors="replace") as f:
for line in f:
line = line.strip()
if not line or line.startswith("VNUM"):
continue
parts = line.split("\t", 1) if "\t" in line else line.split(None, 1)
if len(parts) < 2:
continue
item_names[parts[0]] = parts[1].strip()
except UnicodeDecodeError as e:
print(f"Encoding error in {item_names_filename}: {e}")
print("Using replacement characters for invalid bytes")
except FileNotFoundError:
print(f"Error: {item_names_filename} not found")
except Exception as e:
print(f"Error reading {item_names_filename}: {e}")
return item_names
def annotate_mob_drop_items(mob_drop_filename: str, item_names: dict, output_filename: str) -> None:
pattern = re.compile(r"^\d+\s+(\d+)")
try:
with open(mob_drop_filename, "r", encoding="windows-1254", errors="replace") as fin, \
open(output_filename, "w", encoding="windows-1254") as fout:
for line in fin:
if match := pattern.match(line.strip()):
vnum = match.group(1)
if vnum in item_names:
fout.write(f"{line.rstrip()} -- {item_names[vnum]}\n")
continue
fout.write(line)
except UnicodeDecodeError as e:
print(f"Encoding error in {mob_drop_filename}: {e}")
print("Using replacement characters for invalid bytes")
except FileNotFoundError:
print(f"Error: {mob_drop_filename} not found")
except Exception as e:
print(f"Error processing files: {e}")
def main() -> None:
current_dir = Path.cwd()
item_names_file = current_dir / "item_names.txt"
mob_drop_file = current_dir / "mob_drop_item.txt"
output_file = current_dir / "new_mob_drop_item.txt"
if not item_names_file.exists() or not mob_drop_file.exists():
print("Item names or mob drop file not found")
return
item_names = load_item_names(item_names_file)
if item_names:
annotate_mob_drop_items(mob_drop_file, item_names, output_file)
print(f"Completed: {output_file}")
if __name__ == "__main__":
main()
Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)
Benzer konular
- Cevaplar
- 13
- Görüntüleme
- 2K
- 1.00 yıldız(lar) 1 Değerlendirme
- Cevaplar
- 2
- Görüntüleme
- 623
- Cevaplar
- 215
- Görüntüleme
- 50K










