From 7460aca3e5a7d6de02c5d31900148b0d68facf63 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Wed, 16 Aug 2017 21:34:45 -0230 Subject: [PATCH] zulip_bots: Format string before checking if logo file exists. get_bot_logo_path now first formats the path string with the name of the bot before checking if the path exists. Not doing so is a bug and causes the function to always return None. --- zulip_bots/zulip_bots/lib.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index edfb797..51eb53b 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -25,13 +25,15 @@ def exit_gracefully(signum, frame): def get_bot_logo_path(name): # type: str -> Optional[str] current_dir = os.path.dirname(os.path.abspath(__file__)) - logo_path_png = os.path.join(current_dir, 'bots/{bot_name}/logo.png') - logo_path_svg = os.path.join(current_dir, 'bots/{bot_name}/logo.svg') + logo_path_png = os.path.join( + current_dir, 'bots/{bot_name}/logo.png'.format(bot_name=name)) + logo_path_svg = os.path.join( + current_dir, 'bots/{bot_name}/logo.svg'.format(bot_name=name)) if os.path.isfile(logo_path_png): - return logo_path_png.format(bot_name=name) + return logo_path_png elif os.path.isfile(logo_path_svg): - return logo_path_svg.format(bot_name=name) + return logo_path_svg return None