create cyclePunctuation

This commit is contained in:
chrys87 2016-10-04 16:57:17 +02:00 committed by GitHub
parent aac65c528e
commit 5ce91abb5a

View File

@ -19,10 +19,10 @@ class punctuationManager():
self.allPunctNone[char] = None self.allPunctNone[char] = None
self.punctuation = { self.punctuation = {
'levels':{ 'levels':{
'NONE': '', 'none': '',
'SOME': '#-$~+*-/\\@', 'some': '#-$~+*-/\\@',
'MOST': '.,:-$~+*-/\\@!#%^&*()[]}{<>;', 'most': '.,:-$~+*-/\\@!#%^&*()[]}{<>;',
'ALL': string.punctuation, 'all': string.punctuation,
}, },
'punctuationDict':{ 'punctuationDict':{
'&':'and', '&':'and',
@ -89,10 +89,19 @@ class punctuationManager():
def proceedPunctuation(self, text, ignorePunctuation=False): def proceedPunctuation(self, text, ignorePunctuation=False):
resultText = self.useCustomDict(text, self.punctuation['customDict']) resultText = self.useCustomDict(text, self.punctuation['customDict'])
currPunctLevel = '' currPunctLevel = ''
if not ignorePunctuation and self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').upper() in self.punctuation['levels']: if not ignorePunctuation and self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower() in self.punctuation['levels']:
currPunctLevel = self.punctuation['levels'][self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').upper()] currPunctLevel = self.punctuation['levels'][self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower()]
else: else:
currPunctLevel = string.punctuation currPunctLevel = string.punctuation
resultText = self.usePunctuationDict(resultText, self.punctuation['punctuationDict'], currPunctLevel) resultText = self.usePunctuationDict(resultText, self.punctuation['punctuationDict'], currPunctLevel)
resultText = self.removeUnused(resultText) resultText = self.removeUnused(resultText)
return resultText return resultText
def cyclePunctuation(self):
punctList = list(self.punctuation['levels'].keys())
currIndex = punctList.index(self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower()) # curr punctuation
currIndex += 1
if currIndex >= len(punctList):
currIndex = 0
currLevel = punctList[currIndex]
self.env['runtime']['settingsManager'].setSetting('general', currLevel).lower()