replace replace by sub
This commit is contained in:
parent
59c4a2beb4
commit
7f91223f94
@ -33,15 +33,14 @@ class punctuationManager():
|
|||||||
del currAllPunctNone[ord(char)]
|
del currAllPunctNone[ord(char)]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return text.translate(currAllPunctNone)
|
return text.translate(currAllPunctNone)
|
||||||
|
|
||||||
def useCustomDict(self, text, customDict, seperator=''):
|
def useCustomDict(self, text, customDict, seperator=''):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
if customDict:
|
if customDict:
|
||||||
for key,item in customDict.items():
|
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), str(item), resultText)
|
||||||
return resultText
|
return resultText
|
||||||
|
|
||||||
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
def usePunctuationDict(self, text, punctuationDict, punctuation):
|
||||||
resultText = str(text)
|
resultText = str(text)
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ class punctuationManager():
|
|||||||
if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \
|
if self.env['runtime']['settingsManager'].getSetting('general', 'respectPunctuationPause') and \
|
||||||
len(key) == 1 and \
|
len(key) == 1 and \
|
||||||
key in "',.;:?!":
|
key in "',.;:?!":
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
|
resultText = resultText.replace(str(key),' ' +str(item) + str(key) + ' ')
|
||||||
else:
|
else:
|
||||||
resultText = resultText.replace(str(key),' ' +str(item) + ' ')
|
resultText = resultText.replace(str(key),' ' +str(item) + ' ')
|
||||||
return resultText
|
return resultText
|
||||||
|
@ -87,6 +87,13 @@ class driver(screenDriver):
|
|||||||
self.env = environment
|
self.env = environment
|
||||||
self.command = self.env['runtime']['settingsManager'].getSetting('general','shell')
|
self.command = self.env['runtime']['settingsManager'].getSetting('general','shell')
|
||||||
self.shortcutType = self.env['runtime']['inputManager'].getShortcutType()
|
self.shortcutType = self.env['runtime']['inputManager'].getShortcutType()
|
||||||
|
param = [sys.stdin.fileno(), sys.stdout.fileno(), self.signalPipe, self.p_out, self.p_pid]
|
||||||
|
#param[0] = sys.stdin
|
||||||
|
#param[1] = sys.stdout
|
||||||
|
#param[2] = self.signalPipe
|
||||||
|
#param[3] = self.p_out
|
||||||
|
#param[4] = self.p_pid
|
||||||
|
self.env['runtime']['processManager'].addCustomEventThread(self.terminalEmulation, pargs = param, multiprocess = False)
|
||||||
self.env['runtime']['processManager'].addCustomEventThread(self.terminalEmulation)
|
self.env['runtime']['processManager'].addCustomEventThread(self.terminalEmulation)
|
||||||
def getCurrScreen(self):
|
def getCurrScreen(self):
|
||||||
self.env['screen']['oldTTY'] = 'pty'
|
self.env['screen']['oldTTY'] = 'pty'
|
||||||
@ -153,17 +160,26 @@ class driver(screenDriver):
|
|||||||
return lines, columns
|
return lines, columns
|
||||||
def handleSigwinch(self, *args):
|
def handleSigwinch(self, *args):
|
||||||
os.write(self.signalPipe[1], b'w')
|
os.write(self.signalPipe[1], b'w')
|
||||||
def terminalEmulation(self,active , eventQueue):
|
def terminalEmulation(self,active , eventQueue, param = None):
|
||||||
try:
|
try:
|
||||||
old_attr = termios.tcgetattr(sys.stdin)
|
#stdin = param[0]
|
||||||
tty.setraw(0)
|
stdin = os.fdopen(param[0])
|
||||||
lines, columns = self.getTerminalSize(0)
|
stdout = os.fdopen(param[1])
|
||||||
if self.command == '':
|
signalPipe = param[2]
|
||||||
self.command = screen_utils.getShell()
|
p_outFd = param[3]
|
||||||
self.terminal, self.p_pid, self.p_out = self.openTerminal(columns, lines, self.command)
|
p_pid = param[4]
|
||||||
lines, columns = self.resizeTerminal(self.p_out)
|
old_attr = termios.tcgetattr(stdin)
|
||||||
self.terminal.resize(lines, columns)
|
tty.setraw(0)
|
||||||
fdList = [sys.stdin, self.p_out, self.signalPipe[0]]
|
lines, columns = self.getTerminalSize(0)
|
||||||
|
if self.command == '':
|
||||||
|
self.command = screen_utils.getShell()
|
||||||
|
terminal, p_pid.value, fd = self.openTerminal(columns, lines, self.command)
|
||||||
|
p_outFd.value = os.dup(fd)
|
||||||
|
p_out = fd
|
||||||
|
#p_out = os.fdopen(p_outFd.value, "r+b", 0)
|
||||||
|
lines, columns = self.resizeTerminal(p_out)
|
||||||
|
terminal.resize(lines, columns)
|
||||||
|
fdList = [stdin, p_out, signalPipe[0]]
|
||||||
while active.value:
|
while active.value:
|
||||||
r, _, _ = select(fdList, [], [], 1)
|
r, _, _ = select(fdList, [], [], 1)
|
||||||
# none
|
# none
|
||||||
|
Loading…
Reference in New Issue
Block a user