Permalink
Browse files

Update liblouis to version 3.8, add debug logging functionality and c…

…leanup old workarounds that are no longer necessary (#9015)

* Update liblouis to 3.8

* New and updated braille tables

* Sign liblouis with the NV Access certificate, so NVDA builds of liblouis can be identified as such

* Update to commit 90a808bf which fixes a bug in the python wrapper

* Add a louis helper module

* Typo in logHandler

* Update configSpec

* Integrate louisHelper into the braille module

* Move some logic from braille to louisHelper

* Revert commit 79940e4 as testing reveals that this issue does no longer exist

* Remove another workaround for bugs that are fixed upstream

* louisHelper review action: log at level debug

* Update what's new and correct comment.
  • Loading branch information...
leonardder authored and michaelDCurran committed Dec 6, 2018
1 parent ddab676 commit ec877feab252a8de7ebf4634562d7ba75fd3a9c1
Submodule liblouis updated 158 files
@@ -23,6 +23,7 @@ Import([
louisRootDir = env.Dir("#include/liblouis")
louisSourceDir = louisRootDir.Dir("liblouis")
outDir = sourceDir.Dir("louis")
signExec=env['signExec'] if env['certFile'] else None
RE_AC_INIT = re.compile(r"^AC_INIT\(\[(?P<package>.*)\], \[(?P<version>.*)\], \[(?P<bugReport>.*)\], \[(?P<tarName>.*)\], \[(?P<url>.*)\]\)")
def getLouisVersion():
@@ -74,6 +75,8 @@ sourceFiles = [
]
objs = [env.Object("%s.obj" % f, louisSourceDir.File(f)) for f in sourceFiles]
louisLib = env.SharedLibrary("liblouis", objs)
if signExec:
env.AddPostAction(louisLib[0],[signExec])
env.Install(sourceDir, louisLib)
louisPython = env.Substfile(outDir.File("__init__.py"), louisRootDir.File("python/louis/__init__.py.in"),
@@ -64,7 +64,7 @@ For reference, the following dependencies are included in Git submodules:
* [Sonic](https://github.com/waywardgeek/sonic), commit 4f8c1d11
* [IAccessible2](http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2), commit 21bbb176
* [ConfigObj](https://github.com/DiffSK/configobj), commit 5b5de48
* [liblouis](http://www.liblouis.org/), version 3.7.0
* [liblouis](http://www.liblouis.org/), version 3.8.0, commit 90a808bf
* [Unicode Common Locale Data Repository (CLDR)](http://cldr.unicode.org/) Emoji Annotations, version 34.0
* NVDA images and sounds
* System dlls not present on many systems: mfc90.dll, msvcp90.dll, msvcr90.dll, Microsoft.VC90.CRT.manifest
@@ -13,6 +13,7 @@
import threading
import time
import wx
import louisHelper
import louis
import gui
import winKernel
@@ -417,36 +418,14 @@ def update(self):
mode = louis.dotsIO
if config.conf["braille"]["expandAtCursor"] and self.cursorPos is not None:
mode |= louis.compbrlAtCursor
text=unicode(self.rawText).replace('\0','')
braille, self.brailleToRawPos, self.rawToBraillePos, brailleCursorPos = louis.translate(
self.brailleCells, self.brailleToRawPos, self.rawToBraillePos, self.brailleCursorPos = louisHelper.translate(
[os.path.join(brailleTables.TABLES_DIR, config.conf["braille"]["translationTable"]),
"braille-patterns.cti"],
text,
# liblouis mutates typeform if it is a list.
typeform=tuple(self.rawTextTypeforms) if isinstance(self.rawTextTypeforms, list) else self.rawTextTypeforms,
mode=mode, cursorPos=self.cursorPos or 0)
# liblouis gives us back a character string of cells, so convert it to a list of ints.
# For some reason, the highest bit is set, so only grab the lower 8 bits.
self.brailleCells = [ord(cell) & 255 for cell in braille]
# #2466: HACK: liblouis incorrectly truncates trailing spaces from its output in some cases.
# Detect this and add the spaces to the end of the output.
if self.rawText and self.rawText[-1] == " ":
# rawToBraillePos isn't truncated, even though brailleCells is.
# Use this to figure out how long brailleCells should be and thus how many spaces to add.
correctCellsLen = self.rawToBraillePos[-1] + 1
currentCellsLen = len(self.brailleCells)
if correctCellsLen > currentCellsLen:
self.brailleCells.extend((0,) * (correctCellsLen - currentCellsLen))
if self.cursorPos is not None:
# HACK: The cursorPos returned by liblouis is notoriously buggy (#2947 among other issues).
# rawToBraillePos is usually accurate.
try:
brailleCursorPos = self.rawToBraillePos[self.cursorPos]
except IndexError:
pass
else:
brailleCursorPos = None
self.brailleCursorPos = brailleCursorPos
self.rawText,
typeform=self.rawTextTypeforms,
mode=mode,
cursorPos=self.cursorPos
)
if self.selectionStart is not None and self.selectionEnd is not None:
try:
# Mark the selection.
@@ -1571,6 +1550,7 @@ class BrailleHandler(baseObject.AutoPropertyObject):
]
def __init__(self):
louisHelper.initialize()
self.display = None
self.displaySize = 0
self.mainBuffer = BrailleBuffer(self)
@@ -1604,6 +1584,7 @@ def terminate(self):
self.display.terminate()
self.display = None
_BgThread.stop(timeout=bgThreadStopTimeout)
louisHelper.terminate()
def getTether(self):
return self._tether
@@ -65,6 +65,9 @@ def listTables():
"ar-fa.utb" : "fa-ir-g1.utb",
"da-dk-g16.utb":"da-dk-g16.ctb",
"da-dk-g18.utb":"da-dk-g18.ctb",
"de-de-g0.utb":"de-g0.utb",
"de-de-g1.ctb":"de-g1.ctb",
"de-de-g2.ctb":"de-g2.ctb",
"en-us-comp8.ctb" : "en-us-comp8-ext.utb",
"fr-ca-g1.utb":"fr-bfu-comp6.utb",
"Fr-Ca-g2.ctb":"fr-bfu-g2.ctb",
@@ -83,9 +86,15 @@ def listTables():
# Add builtin tables.
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("ar-ar-comp8.utb", _("Arabic 8 dot computer braille"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("ar-ar-g1.utb", _("Arabic grade 1"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("ar-ar-g2.ctb", _("Arabic grade 2"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("as-in-g1.utb", _("Assamese grade 1"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
@@ -128,13 +137,13 @@ def listTables():
addTable("de-de-comp8.ctb", _("German 8 dot computer braille"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("de-de-g0.utb", _("German grade 0"))
addTable("de-g0.utb", _("German grade 0"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("de-de-g1.ctb", _("German grade 1"))
addTable("de-g1.ctb", _("German grade 1"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("de-de-g2.ctb", _("German grade 2"), contracted=True)
addTable("de-g2.ctb", _("German grade 2"), contracted=True)
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("el.ctb", _("Greek (Greece)"))
@@ -176,6 +185,9 @@ def listTables():
addTable("es-g1.ctb", _("Spanish grade 1"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("es-g2.ctb", _("Spanish grade 2"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
addTable("et-g0.utb", _("Estonian grade 0"))
# Translators: The name of a braille table displayed in the
# braille settings dialog.
@@ -202,6 +202,7 @@
hwIo = boolean(default=false)
audioDucking = boolean(default=false)
gui = boolean(default=false)
louis = boolean(default=false)
[uwpOcr]
language = string(default="")
@@ -168,7 +168,7 @@ def io(self, msg, *args, **kwargs):
self._log(log.IO, msg, args, **kwargs)
def exception(self, msg="", exc_info=True, **kwargs):
"""Log an exception at an appropriate levle.
"""Log an exception at an appropriate level.
Normally, it will be logged at level "ERROR".
However, certain exceptions which aren't considered errors (or aren't errors that we can fix) are expected and will therefore be logged at a lower level.
"""
@@ -0,0 +1,72 @@
#louisHelper.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2018 NV Access Limited, Babbage B.V.
"""Helper module to ease communication to and from liblouis."""
import louis
from logHandler import log
import config
LOUIS_TO_NVDA_LOG_LEVELS = {
louis.LOG_ALL: log.DEBUG,
louis.LOG_DEBUG: log.DEBUG,
louis.LOG_INFO: log.INFO,
louis.LOG_WARN: log.WARNING,
louis.LOG_ERROR: log.ERROR,
louis.LOG_FATAL: log.ERROR,
}
@louis.LogCallback
def louis_log(level, message):
if not _isDebug():
return
NVDALevel = LOUIS_TO_NVDA_LOG_LEVELS.get(level, log.DEBUG)
if not log.isEnabledFor(NVDALevel):
return
message = message.decode("ASCII")
codepath = "liblouis at internal log level %d" % level
log._log(NVDALevel, message, [], codepath=codepath)
def _isDebug():
return config.conf["debugLog"]["louis"]
def initialize():
# Register the liblouis logging callback.
louis.registerLogCallback(louis_log)
# Set the log level to debug.
# The NVDA logging callback will filter messages appropriately,
# i.e. error messages will be logged at the error level.
louis.setLogLevel(louis.LOG_DEBUG)
def terminate():
# Set the log level to off.
louis.setLogLevel(louis.LOG_OFF)
# Unregister the liblouis logging callback.
louis.registerLogCallback(None)
# Free liblouis resources
louis.liblouis.lou_free()
def translate(tableList, inbuf, typeform=None, cursorPos=None, mode=0):
"""
Convenience wrapper for louis.translate that:
* returns a list of integers instead of an string with cells, and
* distinguishes between cursor position 0 (cursor at first character) and None (no cursor at all)
"""
text = unicode(inbuf).replace('\0','')
braille, brailleToRawPos, rawToBraillePos, brailleCursorPos = louis.translate(
tableList,
text,
# liblouis mutates typeform if it is a list.
typeform=tuple(typeform) if isinstance(typeform, list) else typeform,
cursorPos=cursorPos or 0,
mode=mode
)
# liblouis gives us back a character string of cells, so convert it to a list of ints.
# For some reason, the highest bit is set, so only grab the lower 8 bits.
braille = [ord(cell) & 255 for cell in braille]
if cursorPos is None:
brailleCursorPos = None
return braille, brailleToRawPos, rawToBraillePos, brailleCursorPos
@@ -6,9 +6,11 @@ What's New in NVDA
= 2019.1 =
== New Features ==
- New braille tables: Arabic 8 dot computer braille, Arabic grade 2, Spanish grade 2. (#4435)
== Changes ==
- Updated liblouis braille translator to version 3.8.0. (#9013)
== Bug Fixes ==
@@ -18,6 +20,7 @@ What's New in NVDA
== Changes for Developers ==
- NVDA can now be built with all editions of Microsoft Visual Studio 2017 (not just the Community edition). (#8939)
- You can now include log output from liblouis into the NVDA log by setting the louis boolean flag in the debugLogging section of the NVDA configuration. (#4554)
= 2018.4 =

0 comments on commit ec877fe

Please sign in to comment.