Suggest possible bgm name if it is not found (#1178)

* suggest possible bgm name if it is not found

* remove pointless ()

* run black

* ...run updated black
This commit is contained in:
Rainchus 2024-03-05 01:01:17 -06:00 committed by GitHub
parent e6da18503f
commit e303e2a04b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -275,10 +275,18 @@ class SBN:
f.write("\n") f.write("\n")
def lookup_file_id(self, filename: str) -> int: def lookup_file_id(self, filename: str) -> int:
suggestion = ""
for id, sbn_file in enumerate(self.files): for id, sbn_file in enumerate(self.files):
if sbn_file.file_name() == filename: if sbn_file.file_name() == filename:
return id return id
raise Exception(f"File not found: {filename} - is it in the file_id_map?") elif sbn_file.file_name().split("_")[0] == filename.split("_")[0]:
suggestion = sbn_file.file_name()
if suggestion == "":
raise Exception(f"File not found: {filename} - is it in the file_id_map?")
else:
raise Exception(
f"File not found: {filename} - is it in the file_id_map? (Did you mean to name the file: {suggestion}?)"
)
def __str__(self) -> str: def __str__(self) -> str:
s = "SBN(\n" s = "SBN(\n"