More pep8 fixes. A tiny bit of refactoring.

This commit is contained in:
Storm Dragon
2025-07-07 00:42:23 -04:00
parent d28c18faed
commit 3390c25dfe
343 changed files with 11092 additions and 7582 deletions

View File

@ -2,14 +2,15 @@
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
# By Chrys, Storm Dragon, and contributors.
from fenrirscreenreader.core import debug
import re
import string
from fenrirscreenreader.core import debug
class BarrierManager():
class BarrierManager:
def __init__(self):
self.currIsBarrier = False
self.prefIsBarrier = False
@ -32,49 +33,52 @@ class BarrierManager():
return self.currIsBarrier != self.prefIsBarrier
def handle_line_barrier(
self,
text,
xCursor,
yCursor,
output=True,
do_interrupt=True):
self, text, xCursor, yCursor, output=True, do_interrupt=True
):
is_barrier = False
try:
is_barrier, say_line = self.get_barrier_text(text, xCursor, yCursor)
is_barrier, say_line = self.get_barrier_text(
text, xCursor, yCursor
)
except Exception as e:
return False, ''
return False, ""
self.update_barrier_change(is_barrier)
if self.is_barrier_change():
if output:
if is_barrier:
self.env['runtime']['OutputManager'].play_sound_icon(
sound_icon ='BarrierStart', interrupt=do_interrupt)
self.env["runtime"]["OutputManager"].play_sound_icon(
sound_icon="BarrierStart", interrupt=do_interrupt
)
else:
self.env['runtime']['OutputManager'].play_sound_icon(
sound_icon ='BarrierEnd', interrupt=do_interrupt)
self.env["runtime"]["OutputManager"].play_sound_icon(
sound_icon="BarrierEnd", interrupt=do_interrupt
)
if not is_barrier:
say_line = ''
say_line = ""
return is_barrier, say_line
def get_barrier_text(self, text, xCursor, yCursor):
line = text[yCursor]
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
'barrier', 'enabled'):
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
"barrier", "enabled"
):
return False, line
offset = xCursor
left_barriers = self.env['runtime']['SettingsManager'].get_setting(
'barrier', 'left_barriers')
right_barriers = self.env['runtime']['SettingsManager'].get_setting(
'barrier', 'right_barriers')
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 left_barriers:
if line[:offset + 1].count(b) > line[offset:].count(b):
if line[: offset + 1].count(b) > line[offset:].count(b):
offset = xCursor - 1
start = line[:offset].rfind(b)
if start != -1: