Exit from loop if emoji found

main
Bob Mottram 2022-04-19 15:27:59 +01:00
parent a7cb0ead44
commit 82475bb07b
1 changed files with 15 additions and 12 deletions

View File

@ -1680,7 +1680,7 @@ def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
emojis_filename = base_dir + '/emoji/emoji.json'
if not os.path.isfile(emojis_filename):
emojis_filename = base_dir + '/emoji/default_emoji.json'
emojis_json = None
emojis_json = load_json(emojis_filename)
common_emoji_filename = base_dir + '/accounts/common_emoji.txt'
if not os.path.isfile(common_emoji_filename):
@ -1700,6 +1700,8 @@ def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
while ctr < no_of_emoji and line_ctr < len(common_emoji):
emoji_name = common_emoji[line_ctr].split(' ')[1].replace('\n', '')
emoji_filename = base_dir + '/emoji/' + emoji_name + '.png'
if not os.path.isfile(emoji_filename):
emoji_filename = base_dir + '/customemoji/' + emoji_name + '.png'
if not os.path.isfile(emoji_filename):
# load the emojis index
if not emojis_json:
@ -1712,6 +1714,7 @@ def html_common_emoji(base_dir: str, no_of_emoji: int) -> str:
# get the filename based on the hex code
emoji_filename = \
base_dir + '/emoji/' + emoji_name + '.png'
break
if os.path.isfile(emoji_filename):
# NOTE: deliberately no alt text, so that without graphics only
# the emoji name shows