Loading emoji

main2
Bob Mottram 2019-09-29 15:48:17 +01:00
parent f32ee82683
commit c8d25f85cb
1 changed files with 13 additions and 2 deletions

View File

@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
import os import os
import time
import commentjson import commentjson
from shutil import copyfile from shutil import copyfile
@ -259,8 +260,18 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \
print('Loading emoji lookup') print('Loading emoji lookup')
if not os.path.isfile(baseDir+'/emoji/emoji.json'): if not os.path.isfile(baseDir+'/emoji/emoji.json'):
copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json') copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json')
with open(baseDir+'/emoji/emoji.json', 'r') as fp: emojiDictCtr=0
emojiDict=commentjson.load(fp) while not emojiDict and emojiDictCtr<4:
if emojiDictCtr>0:
print('Retry emoji load '+baseDir+'/emoji/emoji.json')
try:
with open(baseDir+'/emoji/emoji.json', 'r') as fp:
emojiDict=commentjson.load(fp)
break
except Exception as e:
print(e)
time.sleep(1)
emojiDictCtr+=1
addEmoji(baseDir,wordStr,httpPrefix,originalDomain,replaceEmoji,hashtags,emojiDict) addEmoji(baseDir,wordStr,httpPrefix,originalDomain,replaceEmoji,hashtags,emojiDict)