[orca] Don't call re.compile() in mathsymbols.py until we need to adjust spoken strings



commit 8c1b45ab159b4d5fe69f9efc6d4ded11e2e93ffb
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Fri Jul 3 15:23:18 2015 -0400

    Don't call re.compile() in mathsymbols.py until we need to adjust spoken strings

 src/orca/mathsymbols.py |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/orca/mathsymbols.py b/src/orca/mathsymbols.py
index 7efa54a..fdf7667 100644
--- a/src/orca/mathsymbols.py
+++ b/src/orca/mathsymbols.py
@@ -2061,7 +2061,14 @@ _all.update(_alnum)
 _all.update(_arrows)
 _all.update(_operators)
 _all.update(_shapes)
-_RE = re.compile('[%s]' % ''.join(list(_all.keys())), re.UNICODE)
+_RE = None
+
+def __compileRE():
+    global _RE
+    try:
+        _RE = re.compile('[%s]' % ''.join(list(_all.keys())), re.UNICODE)
+    except:
+        _RE = None
 
 def _getStyleString(symbol):
     o = ord(symbol)
@@ -2119,6 +2126,11 @@ def getCharacterName(symbol):
     return _getSpokenName(symbol, speakStyle != SPEAK_NEVER)
 
 def adjustForSpeech(string):
+    if _RE is None:
+        __compileRE()
+    if _RE is None:
+        return string
+
     chars = set(re.findall(_RE, string))
     includeStyle = speakStyle == SPEAK_ALWAYS
     for char in chars:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]