Most of the pep8 changes finished. Be careful, things may be horribly broken.
This commit is contained in:
@ -8,7 +8,7 @@ from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class helpManager():
|
||||
class HelpManager():
|
||||
def __init__(self):
|
||||
self.helpDict = {}
|
||||
self.tutorialListIndex = None
|
||||
@ -19,15 +19,15 @@ class helpManager():
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def toggleTutorialMode(self):
|
||||
self.setTutorialMode(not self.env['general']['tutorialMode'])
|
||||
def toggle_tutorial_mode(self):
|
||||
self.set_tutorial_mode(not self.env['general']['tutorialMode'])
|
||||
|
||||
def setTutorialMode(self, newTutorialMode):
|
||||
if self.env['runtime']['vmenuManager'].getActive():
|
||||
def set_tutorial_mode(self, newTutorialMode):
|
||||
if self.env['runtime']['VmenuManager'].get_active():
|
||||
return
|
||||
self.env['general']['tutorialMode'] = newTutorialMode
|
||||
if newTutorialMode:
|
||||
self.createHelpDict()
|
||||
self.create_help_dict()
|
||||
self.env['bindings'][str([1, ['KEY_ESC']])
|
||||
] = 'TOGGLE_TUTORIAL_MODE'
|
||||
self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_HELP'
|
||||
@ -35,27 +35,27 @@ class helpManager():
|
||||
self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_HELP'
|
||||
else:
|
||||
try:
|
||||
self.env['bindings'] = self.env['runtime']['settingsManager'].getBindingBackup(
|
||||
self.env['bindings'] = self.env['runtime']['SettingsManager'].get_binding_backup(
|
||||
)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut(
|
||||
'helpManager setTutorialMode: Error restoring binding backup: ' + str(e),
|
||||
debug.debugLevel.ERROR)
|
||||
self.env['runtime']['DebugManager'].write_debug_out(
|
||||
'HelpManager set_tutorial_mode: Error restoring binding backup: ' + str(e),
|
||||
debug.DebugLevel.ERROR)
|
||||
|
||||
def isTutorialMode(self):
|
||||
def is_tutorial_mode(self):
|
||||
return self.env['general']['tutorialMode']
|
||||
|
||||
def getFormattedShortcutForCommand(self, command):
|
||||
def get_formatted_shortcut_for_command(self, command):
|
||||
shortcut = []
|
||||
rawShortcut = []
|
||||
raw_shortcut = []
|
||||
try:
|
||||
rawShortcut = list(self.env['bindings'].keys())[
|
||||
raw_shortcut = list(self.env['bindings'].keys())[
|
||||
list(self.env['bindings'].values()).index(command)]
|
||||
rawShortcut = self.env['rawBindings'][rawShortcut]
|
||||
raw_shortcut = self.env['rawBindings'][raw_shortcut]
|
||||
# prefer numbers for multitap
|
||||
if rawShortcut[0] in range(2, 9):
|
||||
formattedKey = str(rawShortcut[0]) + ' times '
|
||||
shortcut.append(formattedKey)
|
||||
if raw_shortcut[0] in range(2, 9):
|
||||
formatted_key = str(raw_shortcut[0]) + ' times '
|
||||
shortcut.append(formatted_key)
|
||||
# prefer metha keys
|
||||
for k in [
|
||||
'KEY_FENRIR',
|
||||
@ -64,20 +64,20 @@ class helpManager():
|
||||
'KEY_SHIFT',
|
||||
'KEY_ALT',
|
||||
'KEY_META']:
|
||||
if k in rawShortcut[1]:
|
||||
formattedKey = k
|
||||
formattedKey = formattedKey.lower()
|
||||
formattedKey = formattedKey.replace('key_kp', ' keypad ')
|
||||
formattedKey = formattedKey.replace('key_', ' ')
|
||||
shortcut.append(formattedKey)
|
||||
rawShortcut[1].remove(k)
|
||||
if k in raw_shortcut[1]:
|
||||
formatted_key = k
|
||||
formatted_key = formatted_key.lower()
|
||||
formatted_key = formatted_key.replace('key_kp', ' keypad ')
|
||||
formatted_key = formatted_key.replace('key_', ' ')
|
||||
shortcut.append(formatted_key)
|
||||
raw_shortcut[1].remove(k)
|
||||
# handle other keys
|
||||
for k in rawShortcut[1]:
|
||||
formattedKey = k
|
||||
formattedKey = formattedKey.lower()
|
||||
formattedKey = formattedKey.replace('key_kp', ' keypad ')
|
||||
formattedKey = formattedKey.replace('key_', ' ')
|
||||
shortcut.append(formattedKey)
|
||||
for k in raw_shortcut[1]:
|
||||
formatted_key = k
|
||||
formatted_key = formatted_key.lower()
|
||||
formatted_key = formatted_key.replace('key_kp', ' keypad ')
|
||||
formatted_key = formatted_key.replace('key_', ' ')
|
||||
shortcut.append(formatted_key)
|
||||
except Exception as e:
|
||||
return ''
|
||||
shortcut = str(shortcut)
|
||||
@ -86,48 +86,48 @@ class helpManager():
|
||||
shortcut = shortcut.replace("'", '')
|
||||
return shortcut
|
||||
|
||||
def getCommandHelpText(self, command, section='commands'):
|
||||
commandName = command.lower()
|
||||
commandName = commandName.split('__-__')[0]
|
||||
commandName = commandName.replace('_', ' ')
|
||||
commandName = commandName.replace('_', ' ')
|
||||
def get_command_help_text(self, command, section='commands'):
|
||||
command_name = command.lower()
|
||||
command_name = command_name.split('__-__')[0]
|
||||
command_name = command_name.replace('_', ' ')
|
||||
command_name = command_name.replace('_', ' ')
|
||||
if command == 'TOGGLE_TUTORIAL_MODE':
|
||||
commandDescription = _('toggles the tutorial mode')
|
||||
command_description = _('toggles the tutorial mode')
|
||||
else:
|
||||
commandDescription = self.env['runtime']['commandManager'].getCommandDescription(
|
||||
command_description = self.env['runtime']['CommandManager'].get_command_description(
|
||||
command, section='commands')
|
||||
if commandDescription == '':
|
||||
commandDescription = 'no Description available'
|
||||
commandShortcut = self.getFormattedShortcutForCommand(command)
|
||||
if commandShortcut == '':
|
||||
commandShortcut = 'unbound'
|
||||
helptext = commandName + ', Shortcut ' + \
|
||||
commandShortcut + ', Description ' + commandDescription
|
||||
if command_description == '':
|
||||
command_description = 'no Description available'
|
||||
command_shortcut = self.get_formatted_shortcut_for_command(command)
|
||||
if command_shortcut == '':
|
||||
command_shortcut = 'unbound'
|
||||
helptext = command_name + ', Shortcut ' + \
|
||||
command_shortcut + ', Description ' + command_description
|
||||
return helptext
|
||||
|
||||
def createHelpDict(self, section='commands'):
|
||||
def create_help_dict(self, section='commands'):
|
||||
self.helpDict = {}
|
||||
for command in sorted(self.env['commands'][section].keys()):
|
||||
self.helpDict[len(self.helpDict)] = self.getCommandHelpText(
|
||||
self.helpDict[len(self.helpDict)] = self.get_command_help_text(
|
||||
command, section)
|
||||
if len(self.helpDict) > 0:
|
||||
self.tutorialListIndex = 0
|
||||
else:
|
||||
self.tutorialListIndex = None
|
||||
|
||||
def getHelpForCurrentIndex(self):
|
||||
def get_help_for_current_index(self):
|
||||
if self.tutorialListIndex is None:
|
||||
return ''
|
||||
return self.helpDict[self.tutorialListIndex]
|
||||
|
||||
def nextIndex(self):
|
||||
def next_index(self):
|
||||
if self.tutorialListIndex is None:
|
||||
return
|
||||
self.tutorialListIndex += 1
|
||||
if self.tutorialListIndex >= len(self.helpDict):
|
||||
self.tutorialListIndex = 0
|
||||
|
||||
def prevIndex(self):
|
||||
def prev_index(self):
|
||||
if self.tutorialListIndex is None:
|
||||
return
|
||||
self.tutorialListIndex -= 1
|
||||
|
Reference in New Issue
Block a user