Rewrite TripElement.get_emoji() to use dict lookup

This commit is contained in:
Edward Betts 2024-05-19 08:59:27 +02:00
parent 277e991869
commit 1948ab8ff5

View file

@ -44,16 +44,17 @@ class TripElement:
detail: StrDict
def get_emoji(self) -> str | None:
"""Emjoji for trip element."""
if self.element_type in ("check-in", "check-out"):
return emoji.emojize(":hotel:", language="alias")
if self.element_type == "train":
return emoji.emojize(":train:", language="alias")
if self.element_type == "flight":
return emoji.emojize(":airplane:", language="alias")
if self.element_type == "ferry":
return emoji.emojize(":ferry:", language="alias")
return None
"""Emoji for trip element."""
emoji_map = {
"check-in": ":hotel:",
"check-out": ":hotel:",
"train": ":train:",
"flight": ":airplane:",
"ferry": ":ferry:",
}
alias = emoji_map.get(self.element_type)
return emoji.emojize(alias, language="alias") if alias else None
def airport_label(airport: StrDict) -> str: