Core/Docs: Adding apostrophe quotes around variables in printed error messages (#3914)
* Also indents plando_connections properly * Adding apostrophe quotes around item, location, entrance/exit and boss names to make errors more readable * Update plando_en.md * Fixing test in Lufia II
This commit is contained in:
parent
2e0769c90e
commit
de3707af4a
30
Options.py
30
Options.py
|
@ -496,7 +496,7 @@ class TextChoice(Choice):
|
||||||
|
|
||||||
def __init__(self, value: typing.Union[str, int]):
|
def __init__(self, value: typing.Union[str, int]):
|
||||||
assert isinstance(value, str) or isinstance(value, int), \
|
assert isinstance(value, str) or isinstance(value, int), \
|
||||||
f"{value} is not a valid option for {self.__class__.__name__}"
|
f"'{value}' is not a valid option for '{self.__class__.__name__}'"
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -617,17 +617,17 @@ class PlandoBosses(TextChoice, metaclass=BossMeta):
|
||||||
used_locations.append(location)
|
used_locations.append(location)
|
||||||
used_bosses.append(boss)
|
used_bosses.append(boss)
|
||||||
if not cls.valid_boss_name(boss):
|
if not cls.valid_boss_name(boss):
|
||||||
raise ValueError(f"{boss.title()} is not a valid boss name.")
|
raise ValueError(f"'{boss.title()}' is not a valid boss name.")
|
||||||
if not cls.valid_location_name(location):
|
if not cls.valid_location_name(location):
|
||||||
raise ValueError(f"{location.title()} is not a valid boss location name.")
|
raise ValueError(f"'{location.title()}' is not a valid boss location name.")
|
||||||
if not cls.can_place_boss(boss, location):
|
if not cls.can_place_boss(boss, location):
|
||||||
raise ValueError(f"{location.title()} is not a valid location for {boss.title()} to be placed.")
|
raise ValueError(f"'{location.title()}' is not a valid location for {boss.title()} to be placed.")
|
||||||
else:
|
else:
|
||||||
if cls.duplicate_bosses:
|
if cls.duplicate_bosses:
|
||||||
if not cls.valid_boss_name(option):
|
if not cls.valid_boss_name(option):
|
||||||
raise ValueError(f"{option} is not a valid boss name.")
|
raise ValueError(f"'{option}' is not a valid boss name.")
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"{option.title()} is not formatted correctly.")
|
raise ValueError(f"'{option.title()}' is not formatted correctly.")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_place_boss(cls, boss: str, location: str) -> bool:
|
def can_place_boss(cls, boss: str, location: str) -> bool:
|
||||||
|
@ -817,15 +817,15 @@ class VerifyKeys(metaclass=FreezeValidKeys):
|
||||||
for item_name in self.value:
|
for item_name in self.value:
|
||||||
if item_name not in world.item_names:
|
if item_name not in world.item_names:
|
||||||
picks = get_fuzzy_results(item_name, world.item_names, limit=1)
|
picks = get_fuzzy_results(item_name, world.item_names, limit=1)
|
||||||
raise Exception(f"Item {item_name} from option {self} "
|
raise Exception(f"Item '{item_name}' from option '{self}' "
|
||||||
f"is not a valid item name from {world.game}. "
|
f"is not a valid item name from '{world.game}'. "
|
||||||
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure)")
|
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure)")
|
||||||
elif self.verify_location_name:
|
elif self.verify_location_name:
|
||||||
for location_name in self.value:
|
for location_name in self.value:
|
||||||
if location_name not in world.location_names:
|
if location_name not in world.location_names:
|
||||||
picks = get_fuzzy_results(location_name, world.location_names, limit=1)
|
picks = get_fuzzy_results(location_name, world.location_names, limit=1)
|
||||||
raise Exception(f"Location {location_name} from option {self} "
|
raise Exception(f"Location '{location_name}' from option '{self}' "
|
||||||
f"is not a valid location name from {world.game}. "
|
f"is not a valid location name from '{world.game}'. "
|
||||||
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure)")
|
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure)")
|
||||||
|
|
||||||
def __iter__(self) -> typing.Iterator[typing.Any]:
|
def __iter__(self) -> typing.Iterator[typing.Any]:
|
||||||
|
@ -1111,11 +1111,11 @@ class PlandoConnections(Option[typing.List[PlandoConnection]], metaclass=Connect
|
||||||
used_entrances.append(entrance)
|
used_entrances.append(entrance)
|
||||||
used_exits.append(exit)
|
used_exits.append(exit)
|
||||||
if not cls.validate_entrance_name(entrance):
|
if not cls.validate_entrance_name(entrance):
|
||||||
raise ValueError(f"{entrance.title()} is not a valid entrance.")
|
raise ValueError(f"'{entrance.title()}' is not a valid entrance.")
|
||||||
if not cls.validate_exit_name(exit):
|
if not cls.validate_exit_name(exit):
|
||||||
raise ValueError(f"{exit.title()} is not a valid exit.")
|
raise ValueError(f"'{exit.title()}' is not a valid exit.")
|
||||||
if not cls.can_connect(entrance, exit):
|
if not cls.can_connect(entrance, exit):
|
||||||
raise ValueError(f"Connection between {entrance.title()} and {exit.title()} is invalid.")
|
raise ValueError(f"Connection between '{entrance.title()}' and '{exit.title()}' is invalid.")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_any(cls, data: PlandoConFromAnyType) -> Self:
|
def from_any(cls, data: PlandoConFromAnyType) -> Self:
|
||||||
|
@ -1379,8 +1379,8 @@ class ItemLinks(OptionList):
|
||||||
picks_group = get_fuzzy_results(item_name, world.item_name_groups.keys(), limit=1)
|
picks_group = get_fuzzy_results(item_name, world.item_name_groups.keys(), limit=1)
|
||||||
picks_group = f" or '{picks_group[0][0]}' ({picks_group[0][1]}% sure)" if allow_item_groups else ""
|
picks_group = f" or '{picks_group[0][0]}' ({picks_group[0][1]}% sure)" if allow_item_groups else ""
|
||||||
|
|
||||||
raise Exception(f"Item {item_name} from item link {item_link} "
|
raise Exception(f"Item '{item_name}' from item link '{item_link}' "
|
||||||
f"is not a valid item from {world.game} for {pool_name}. "
|
f"is not a valid item from '{world.game}' for '{pool_name}'. "
|
||||||
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure){picks_group}")
|
f"Did you mean '{picks[0][0]}' ({picks[0][1]}% sure){picks_group}")
|
||||||
if allow_item_groups:
|
if allow_item_groups:
|
||||||
pool |= world.item_name_groups.get(item_name, {item_name})
|
pool |= world.item_name_groups.get(item_name, {item_name})
|
||||||
|
|
|
@ -50,8 +50,8 @@ class TestVerifyItemName(L2ACTestBase):
|
||||||
|
|
||||||
def test_verify_item_name(self) -> None:
|
def test_verify_item_name(self) -> None:
|
||||||
self.assertRaisesRegex(Exception,
|
self.assertRaisesRegex(Exception,
|
||||||
"Item The car blade from option CustomItemPool\\(The car blade: 2\\) is not a "
|
"Item 'The car blade' from option 'CustomItemPool\\(The car blade: 2\\)' is not a "
|
||||||
"valid item name from Lufia II Ancient Cave\\. Did you mean 'Dekar blade'",
|
"valid item name from 'Lufia II Ancient Cave'\\. Did you mean 'Dekar blade'",
|
||||||
lambda: handle_option(Namespace(game="Lufia II Ancient Cave", name="Player"),
|
lambda: handle_option(Namespace(game="Lufia II Ancient Cave", name="Player"),
|
||||||
self.options, "custom_item_pool", CustomItemPool,
|
self.options, "custom_item_pool", CustomItemPool,
|
||||||
PlandoOptions(0)))
|
PlandoOptions(0)))
|
||||||
|
|
Loading…
Reference in New Issue