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.
This commit is contained in:
Eeshan Garg 2017-08-16 21:34:45 -02:30 committed by Tim Abbott
parent c61d413f25
commit 7460aca3e5

View file

@ -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