From 1948ab8ff53e03595f82678c92977b8ef71d2d8f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 19 May 2024 08:59:27 +0200 Subject: [PATCH] Rewrite TripElement.get_emoji() to use dict lookup --- agenda/types.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/agenda/types.py b/agenda/types.py index be5232f..04c3970 100644 --- a/agenda/types.py +++ b/agenda/types.py @@ -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: