def refreshTablesCache(): global tables, tablesFN, tablesUFN, tablesTR tables = brailleTables.listTables() tablesFN = [t[0] for t in brailleTables.listTables()] tablesUFN = [ t[0] for t in brailleTables.listTables() if not t.contracted and t.output ] tablesTR = [t[1] for t in brailleTables.listTables()]
def loadPreferedTables(): global inputTables, outputTables listInputTables = [table[0] for table in brailleTables.listTables() if table.input] listOutputTables = [table[0] for table in brailleTables.listTables() if table.output] inputTables = config.conf["brailleExtender"]["inputTables"] outputTables = config.conf["brailleExtender"]["outputTables"] if not isinstance(inputTables, list): inputTables = inputTables.replace(', ', ',').split(',') if not isinstance(outputTables, list): outputTables = outputTables.replace(', ', ',').split(',') inputTables = [t for t in inputTables if t in listInputTables] outputTables = [t for t in outputTables if t in listOutputTables]
def translateTable(tableFilename): if tableFilename == "*": return _("all tables") for table in brailleTables.listTables(): if table.fileName == tableFilename: return table.displayName return tableFilename
def test_tableExistence(self): """Tests whether all defined tables exist.""" tables = brailleTables.listTables() for table in tables: self.assertTrue( os.path.isfile( os.path.join(brailleTables.TABLES_DIR, table.fileName)), msg="{table} table not found".format(table=table.displayName))
def test_tableExistence(self): """Tests whether all defined tables exist.""" tables = brailleTables.listTables() for table in tables: self.assertTrue( os.path.isfile(os.path.join(brailleTables.TABLES_DIR, table.fileName)), msg="{table} table not found".format(table=table.displayName) )
def script_switchInputBrailleTable(self, gesture): if configBE.noUnicodeTable: return ui.message(_("Please use NVDA 2017.3 minimum for this feature")) if len(configBE.iTables) < 2: return ui.message(_('You must choose at least two tables for this feature. Please fill in the settings')) if not config.conf["braille"]["inputTable"] in configBE.iTables: configBE.iTables.append(config.conf["braille"]["inputTable"]) tid = configBE.iTables.index(config.conf["braille"]["inputTable"]) nID = tid + 1 if tid + 1 < len(configBE.iTables) else 0 brailleInput.handler.table = brailleTables.listTables( )[configBE.tablesFN.index(configBE.iTables[nID])] ui.message(_('Input: %s') % brailleInput.handler.table.displayName) return
def loadConf(): global conf, reviewModeApps, quickLaunches, gesturesFileExists, iTables, oTables, profileFileExists, iniProfile confspec = ConfigObj(StringIO(""" [general] autoCheckUpdate = boolean(default=True) channelUpdate = option("stable", "dev", default="stable") lastCheckUpdate = float(min=0, default=0) profile_{CUR_BD} = string(default="default") keyboardLayout_{CUR_BD} = string(default={KEYBOARDLAYOUT}) showConstructST = boolean(default=True) brailleDisplay1 = string(default="noBraille") brailleDisplay2 = string(default="noBraille") reportVolumeBraille = boolean(default=True) reportVolumeSpeech = boolean(default=False) reviewModeApps = string(default="cmd, putty, bash, powershell") hourDynamic = boolean(default=True) limitCells_{CUR_BD} = integer(min=0, default=0, max={MAX_CELLS}) delayScroll_{CUR_BD} = float(min=0, default=3, max={MAX_DELAYSCROLL}) smartDelayScroll = boolean(default=False) reverseScroll = boolean(default=False) ignoreBlankLineScroll = boolean(default=True) speakScroll = boolean(default=True) alwaysSpeakScroll = boolean(default=True) speakRoutingTo = boolean(default=True) iTableShortcuts = string(default="?") iTables = string(default="{ITABLE}") oTables = string(default="{OTABLE}") quickLaunchGestures_{CUR_BD} = string(default="{QLGESTURES}") quickLaunchLocations_{CUR_BD} = string(default="notepad; wordpad; calc; cmd") attribra = boolean(default=True) tabSpace = boolean(default=False) tabSize = integer(min=1, default=2, max=42) postTable = string(default="None") [patch] updateBraille = boolean(default=True) scrollBraille = boolean(default=True) """.format( CUR_BD=curBD, MAX_BD=42, ITABLE=config.conf["braille"]["inputTable"] + ', unicode-braille.utb', OTABLE=config.conf["braille"]["translationTable"], MAX_CELLS=420, MAX_DELAYSCROLL=999, MAX_TABLES=420, KEYBOARDLAYOUT=iniProfile['keyboardLayouts'].keys()[0] if 'keyboardLayouts' in iniProfile.keys() else None, QLGESTURES=iniProfile['miscs']['defaultQuickLaunches'] if 'miscs' in iniProfile.keys() else '' )), encoding="UTF-8", list_values=False) confspec.initial_comment = ['%s (%s)' % (_addonName, _addonVersion), _addonURL] confspec.final_comment = ['End Of File'] confspec.newlines = "\n" conf = ConfigObj(cfgFile, configspec=confspec, indent_type="\t", encoding="UTF-8") result = conf.validate(Validator()) if result is not True: log.error('Malformed configuration file') return False else: confspec = ConfigObj(StringIO(""""""), encoding="UTF-8", list_values=False) confGen = ('%s\%s\%s\profile.ini' % (profilesDir, curBD, conf["general"]["profile_%s" % curBD])) if (curBD != 'noBraille' and osp.exists(confGen)): profileFileExists = True iniProfile = ConfigObj(confGen, configspec=confspec, indent_type="\t", encoding="UTF-8") result = iniProfile.validate(Validator()) if result is not True: log.exception('Malformed configuration file') return False else: if curBD != 'noBraille': log.warn('%s inaccessible' % confGen) else: log.debug('No braille display present') if (conf['general']['limitCells_' + curBD] <= backupDisplaySize and conf['general']['limitCells_' + curBD] > 0): braille.handler.displaySize = conf['general']['limitCells_' + curBD] reviewModeApps = [k.strip() for k in conf["general"]["reviewModeApps"].split(',') if k.strip() != ''] tmp1 = [k.strip() for k in conf["general"]["quickLaunchGestures_%s" % curBD].split(';') if k.strip() != ''] tmp2 = [k.strip() for k in conf["general"]["quickLaunchLocations_%s" % curBD].split(';') if k.strip() != ''] for i, gesture in enumerate(tmp1): if i >= len(tmp2): break quickLaunches[gesture] = tmp2[i] if not noUnicodeTable: lITables = [table[0] for table in brailleTables.listTables() if table.input] lOTables = [table[0] for table in brailleTables.listTables() if table.output] iTables = conf['general']['iTables'] oTables = conf['general']['oTables'] if not isinstance(iTables, list): iTables = iTables.replace(', ', ',').split(',') if not isinstance(oTables, list): oTables = oTables.replace(', ', ',').split(',') iTables = [t for t in iTables if t in lITables] oTables = [t for t in oTables if t in lOTables] return True
_addonDir = osp.join(osp.dirname(__file__), "..", "..").decode("mbcs") _addonName = addonHandler.Addon(_addonDir).manifest['name'] _addonVersion = addonHandler.Addon(_addonDir).manifest['version'] _addonURL = addonHandler.Addon(_addonDir).manifest['url'] _addonAuthor = addonHandler.Addon(_addonDir).manifest['author'] _addonDesc = addonHandler.Addon(_addonDir).manifest['description'] profilesDir = osp.join(osp.dirname(__file__), "Profiles").decode('mbcs') if not osp.exists(profilesDir): log.error('Profiles\' path not found') else: log.debug('Profiles\' path (%s) found' % profilesDir) begFileAttribra = """# Attribra for BrailleExtender # Thanks to Alberto Zanella # -> https://github.com/albzan/attribra/ """ try: import brailleTables tablesFN = [t[0] for t in brailleTables.listTables()] tablesUFN = [t[0] for t in brailleTables.listTables() if not t.contracted and t.output] tablesTR = [t[1] for t in brailleTables.listTables()] noUnicodeTable = False except BaseException: noUnicodeTable = True def loadConf(): global conf, reviewModeApps, quickLaunches, gesturesFileExists, iTables, oTables, profileFileExists, iniProfile confspec = ConfigObj(StringIO(""" [general] autoCheckUpdate = boolean(default=True) channelUpdate = option("stable", "dev", default="stable") lastCheckUpdate = float(min=0, default=0) profile_{CUR_BD} = string(default="default") keyboardLayout_{CUR_BD} = string(default={KEYBOARDLAYOUT})
def isContractedTable(table): if not table in tablesFN: return False tablePos = tablesFN.index(table) if brailleTables.listTables()[tablePos].contracted: return True return False
postTable = [] baseDir = os.path.dirname(__file__).decode("mbcs") _addonDir = os.path.join(baseDir, "..", "..") _addonName = addonHandler.Addon(_addonDir).manifest["name"] _addonVersion = addonHandler.Addon(_addonDir).manifest["version"] _addonURL = addonHandler.Addon(_addonDir).manifest["url"] _addonAuthor = addonHandler.Addon(_addonDir).manifest["author"] _addonDesc = addonHandler.Addon(_addonDir).manifest["description"] profilesDir = os.path.join(baseDir, "Profiles") if not os.path.exists(profilesDir): log.error('Profiles\' path not found') else: log.debug('Profiles\' path (%s) found' % profilesDir) try: import brailleTables brailleTablesDir = brailleTables.TABLES_DIR tables = brailleTables.listTables() tablesFN = [t[0] for t in brailleTables.listTables()] tablesUFN = [ t[0] for t in brailleTables.listTables() if not t.contracted and t.output ] tablesTR = [t[1] for t in brailleTables.listTables()] noUnicodeTable = False except BaseException: noUnicodeTable = True def getValidBrailleDisplayPrefered(): l = braille.getDisplayList() l.append(("last", _("last known"))) return l
def test_renamedTableExistence(self): """Tests whether all defined renamed tables are part of the actual list of tables.""" tableNames = [table.fileName for table in brailleTables.listTables()] for name in brailleTables.RENAMED_TABLES.values(): self.assertIn(name, tableNames)
import braille import brailleTables import controlTypes import core import inputCore import scriptHandler import ui addonHandler.initTranslation() from logHandler import log import configBE import queueHandler import glob import os lastCaptured = None tables = brailleTables.listTables() restartNVDA_ = False instanceGP = None class Settings(wx.Dialog): def __init__(self): if instanceGP.instanceST is not None or instanceGP is None: return instanceGP.instanceST = self wx.Dialog.__init__(self, None, title=_('BrailleExtender settings')) configBE.loadConfAttribra() self.p = wx.Panel(self) self.nb = wx.Notebook(self.p) self.general = General(self.nb)
def test_renamedTableExistence(self): """Tests whether all defined renamed tables are part of the actual list of tables.""" tableNames = [table.fileName for table in brailleTables.listTables()] for name in brailleTables.RENAMED_TABLES.itervalues(): self.assertIn(name, tableNames)