From 9ad5b340026f399815564d63b0040601b54c2e70 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 9 Oct 2019 19:32:53 +0100 Subject: [PATCH] No second colon --- content.py | 38 +++++++++++++++++--------------------- webinterface.py | 5 +---- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/content.py b/content.py index 5695b98d..281fe29b 100644 --- a/content.py +++ b/content.py @@ -311,29 +311,25 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ if ':' in wordStr: print('TAG: emoji located - '+wordStr) wordStr2=wordStr.split(':')[1] - print('TAG: wordStr2a - '+wordStr2) - if ':' in wordStr2: - wordStr2=wordStr2.split(':')[0] - print('TAG: wordStr2b - '+wordStr2) - if not emojiDict: - print('Loading emoji lookup') - if not os.path.isfile(baseDir+'/emoji/emoji.json'): - copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json') - emojiDictCtr=0 - 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('Failed to load emoji: '+baseDir+'/emoji/emoji.json '+str(e)) - time.sleep(1) + if not emojiDict: + print('Loading emoji lookup') + if not os.path.isfile(baseDir+'/emoji/emoji.json'): + copyfile(baseDir+'/emoji/default_emoji.json',baseDir+'/emoji/emoji.json') + emojiDictCtr=0 + 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('Failed to load emoji: '+baseDir+'/emoji/emoji.json '+str(e)) + time.sleep(1) emojiDictCtr+=1 - print('TAG: looking up emoji for :'+wordStr2+':') - addEmoji(baseDir,':'+wordStr2+':',httpPrefix,originalDomain,replaceEmoji,hashtags,emojiDict) + print('TAG: looking up emoji for :'+wordStr2+':') + addEmoji(baseDir,':'+wordStr2+':',httpPrefix,originalDomain,replaceEmoji,hashtags,emojiDict) # replace words with their html versions for wordStr,replaceStr in replaceMentions.items(): diff --git a/webinterface.py b/webinterface.py index 8aa556c8..022a8f04 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1637,10 +1637,7 @@ def addEmojiToDisplayName(baseDir: str,httpPrefix: str, \ # remove any stray emoji while ':' in displayName: - nameStr=displayName.split(':')[1] - if ':' not in nameStr: - break - emojiStr=nameStr.split(':')[0] + emojiStr=displayName.split(':')[1] displayName=displayName.replace(':'+emojiStr+':','').strip() print('TAG: displayName after tags 3: '+displayName) print('TAG: displayName after tag replacements: '+displayName)