From 1155103389715321ba2c0b720571082418924110 Mon Sep 17 00:00:00 2001 From: Chrys Date: Thu, 29 Aug 2019 17:55:19 +0200 Subject: [PATCH] replace replace by sub --- src/fenrirscreenreader/core/punctuationManager.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/fenrirscreenreader/core/punctuationManager.py b/src/fenrirscreenreader/core/punctuationManager.py index a98577ea..f7c6bfb6 100644 --- a/src/fenrirscreenreader/core/punctuationManager.py +++ b/src/fenrirscreenreader/core/punctuationManager.py @@ -33,15 +33,14 @@ class punctuationManager(): del currAllPunctNone[ord(char)] except: pass - return text.translate(currAllPunctNone) - + return text.translate(currAllPunctNone) def useCustomDict(self, text, customDict, seperator=''): resultText = str(text) if customDict: for key,item in customDict.items(): - resultText = resultText.replace(str(key),seperator + str(item) + seperator) + #resultText = resultText.replace(str(key),seperator + str(item) + seperator) + resultText = re.sub(str(key), seperator + str(item) + seperator, resultText) return resultText - def usePunctuationDict(self, text, punctuationDict, punctuation): resultText = str(text) @@ -53,7 +52,7 @@ class punctuationManager(): if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \ len(key) == 1 and \ key in "',.;:?!": - resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ') + resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ') else: resultText = resultText.replace(str(key),' ' +str(item) + ' ') return resultText