Rewrite TripElement.get_emoji() to use dict lookup
This commit is contained in:
parent
277e991869
commit
1948ab8ff5
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue