Most of the pep8 changes finished. Be careful, things may be horribly broken.
This commit is contained in:
@ -9,7 +9,7 @@ import re
|
||||
import string
|
||||
|
||||
|
||||
class barrierManager():
|
||||
class BarrierManager():
|
||||
def __init__(self):
|
||||
self.currIsBarrier = False
|
||||
self.prefIsBarrier = False
|
||||
@ -20,60 +20,60 @@ class barrierManager():
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def updateBarrierChange(self, isBarrier):
|
||||
def update_barrier_change(self, is_barrier):
|
||||
self.prefIsBarrier = self.currIsBarrier
|
||||
self.currIsBarrier = isBarrier
|
||||
self.currIsBarrier = is_barrier
|
||||
|
||||
def resetBarrierChange(self):
|
||||
def reset_barrier_change(self):
|
||||
self.currIsBarrier = False
|
||||
self.prefIsBarrier = False
|
||||
|
||||
def isBarrierChange(self):
|
||||
def is_barrier_change(self):
|
||||
return self.currIsBarrier != self.prefIsBarrier
|
||||
|
||||
def handleLineBarrier(
|
||||
def handle_line_barrier(
|
||||
self,
|
||||
text,
|
||||
xCursor,
|
||||
yCursor,
|
||||
output=True,
|
||||
doInterrupt=True):
|
||||
isBarrier = False
|
||||
do_interrupt=True):
|
||||
is_barrier = False
|
||||
try:
|
||||
isBarrier, sayLine = self.getBarrierText(text, xCursor, yCursor)
|
||||
is_barrier, say_line = self.get_barrier_text(text, xCursor, yCursor)
|
||||
except Exception as e:
|
||||
return False, ''
|
||||
|
||||
self.updateBarrierChange(isBarrier)
|
||||
if self.isBarrierChange():
|
||||
self.update_barrier_change(is_barrier)
|
||||
if self.is_barrier_change():
|
||||
if output:
|
||||
if isBarrier:
|
||||
self.env['runtime']['outputManager'].playSoundIcon(
|
||||
soundIcon='BarrierStart', interrupt=doInterrupt)
|
||||
if is_barrier:
|
||||
self.env['runtime']['OutputManager'].play_sound_icon(
|
||||
sound_icon ='BarrierStart', interrupt=do_interrupt)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].playSoundIcon(
|
||||
soundIcon='BarrierEnd', interrupt=doInterrupt)
|
||||
self.env['runtime']['OutputManager'].play_sound_icon(
|
||||
sound_icon ='BarrierEnd', interrupt=do_interrupt)
|
||||
|
||||
if not isBarrier:
|
||||
sayLine = ''
|
||||
return isBarrier, sayLine
|
||||
if not is_barrier:
|
||||
say_line = ''
|
||||
return is_barrier, say_line
|
||||
|
||||
def getBarrierText(self, text, xCursor, yCursor):
|
||||
def get_barrier_text(self, text, xCursor, yCursor):
|
||||
line = text[yCursor]
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'barrier', 'enabled'):
|
||||
return False, line
|
||||
offset = xCursor
|
||||
|
||||
leftBarriers = self.env['runtime']['settingsManager'].getSetting(
|
||||
'barrier', 'leftBarriers')
|
||||
rightBarriers = self.env['runtime']['settingsManager'].getSetting(
|
||||
'barrier', 'rightBarriers')
|
||||
left_barriers = self.env['runtime']['SettingsManager'].get_setting(
|
||||
'barrier', 'left_barriers')
|
||||
right_barriers = self.env['runtime']['SettingsManager'].get_setting(
|
||||
'barrier', 'right_barriers')
|
||||
# is the cursor at the begin or end of an entry:
|
||||
# print(line[:offset + 1].count('│'),line[offset:].count('│'))
|
||||
# start
|
||||
|
||||
for b in leftBarriers:
|
||||
for b in left_barriers:
|
||||
if line[:offset + 1].count(b) > line[offset:].count(b):
|
||||
offset = xCursor - 1
|
||||
start = line[:offset].rfind(b)
|
||||
@ -83,7 +83,7 @@ class barrierManager():
|
||||
if start == -1:
|
||||
return False, line
|
||||
# end
|
||||
for b in rightBarriers:
|
||||
for b in right_barriers:
|
||||
end = line[start:].find(b)
|
||||
if end != -1:
|
||||
end = start + end
|
||||
|
Reference in New Issue
Block a user